Sign in to follow this  

Java - I cant believe this, cant get simple class to run off command-line

This topic is 4691 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been doing this for so long I'm nearly about to start crying (see diagram above, left) The java executable just will not seem to load the class from the local directory. Ive trawled 'hello world' sites, this is supposed to work. They suggested clobbering the classpath to nothing and that hasnt done anything. Can someone please point out what I'm doing that is obviously so stupid? out the dos box: >dir 12/02/2005 02:57 <DIR> . 12/02/2005 02:57 <DIR> .. 12/02/2005 04:31 2,083 VelocityLauncher.java 1 File(s) 2,083 bytes 2 Dir(s) 138,976,657,408 bytes free >javac VelocityLauncher.java >dir 12/02/2005 02:57 <DIR> . 12/02/2005 02:57 <DIR> .. 12/02/2005 04:31 2,083 VelocityLauncher.java 12/02/2005 04:40 2,394 VelocityLauncher.class 2 File(s) 4,477 bytes 2 Dir(s) 138,976,624,640 bytes free >java VelocityLauncher Exception in thread "main" java.lang.NoClassDefFoundError: VelocityLauncher I should add, the VelocityLauncher class-name appears exactly in that case in the source, thats the first thing I checked:
import ...

class VelocityLauncher{

	void main( String[] args){
		...
	}
}




Share this post


Link to post
Share on other sites
Almost, but not quite. In Java, the main method is declared slightly differently than what you have, e.g. :

class VelocityLauncher{

public static void main( String[] args){
// do some cool stuff
}
}


That should fix your problem.

Share this post


Link to post
Share on other sites
yes!

thanks guys

(not sure where brian's suggestion of classpath=. has gone)

adding

set classpath=%classpath%;.

worked wonders

completely forgot the static, so thats 2 probs sorted.

thank god, I can go to sleep now.

regards

Share this post


Link to post
Share on other sites

This topic is 4691 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this