Multiple Classes

Reply

Join Date: Aug 2004
Posts: 350
Reputation: Ghost is an unknown quantity at this point 
Solved Threads: 2
Ghost's Avatar
Ghost Ghost is offline Offline
Posting Whiz

Multiple Classes

 
0
  #1
May 7th, 2005
Hi,

I'm trying the Space Invaders tutorial (http://www.planetalia.com/cursos/index.jsp). I'm on part 13, which divides the code into classes. I'm using JBuilder and when I do this, I get error messages saying that the class I put in a new Java file doesn't exist. I put the java file in the same directory as the main class.

Can somebody please tell me what I'm doing wrong?

Thank you.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 181
Reputation: Paul.Esson is an unknown quantity at this point 
Solved Threads: 10
Paul.Esson's Avatar
Paul.Esson Paul.Esson is offline Offline
Junior Poster

Re: Multiple Classes

 
0
  #2
May 7th, 2005
I can't give you much advice since I use eclipse. But check to see if the Classes are part of the same Package.

a package is eqivilent to a namespace in .NET.. Hope this helps

Paul
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 350
Reputation: Ghost is an unknown quantity at this point 
Solved Threads: 2
Ghost's Avatar
Ghost Ghost is offline Offline
Posting Whiz

Re: Multiple Classes

 
0
  #3
May 7th, 2005
thanx! one more question: do all the classes have to be in the same package?
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 181
Reputation: Paul.Esson is an unknown quantity at this point 
Solved Threads: 10
Paul.Esson's Avatar
Paul.Esson Paul.Esson is offline Offline
Junior Poster

Re: Multiple Classes

 
0
  #4
May 7th, 2005
no. if there not you can use

import whatever.you.called.it;

example
  1. import java.math;

to import the java.math package (standard java package) if you wish to import say all packages in java.security you could use

  1. import java.security.*;

Some people think its bad coding practice to do this though. I don't find it that messy and i think the jre could manage it ok (it does do optermizations).
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Multiple Classes

 
0
  #5
May 7th, 2005
Compile the class you just created and JBuilder will see it. Sometimes it's not quite smart enough to see classes it created itself unless they're compiled.

As to packages: no, classes don't need to be all in the same package.
And a good thing too as otherwise you'd never be able to use any of the standard library which are all classes in packages.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC