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.

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

thanx! one more question: do all the classes have to be in the same package?

no. if there not you can use

import whatever.you.called.it;

example

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

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).

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.