Sign in to follow this  

[java] Windows - Java - Problems

This topic is 4854 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 am having a slight problem in Windows with running java programs from the command prompt. Basically, I can compile the programs but when i run a java program (ie. c:\java Test) it throws a
Exception in thread "main" java.lang.NoClassDefFoundError: Test
anyway, long story short. I run this within eclipse or even netbeans, the program runs. I reboot to linux, run it there from a terminal window, runs fine. I figured this had something to do with my path settings..so i checked those, those looked ok. So I can't figure out why it allows me to compile the program, but not run it from the command line. Any thoughts? ippo.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
is your program called 'java test', including a space in the name ? if so, make a program with a proper name (without spaces) and it should run fine.
you can always try calling it using quotes, ie "c:\java test", which is probably what Eclipse does anyway.

Share this post


Link to post
Share on other sites
i guess i shouldn't really say program, that might be throwing you off. I mean the class name is "Test" (this is arbitrary anyway) and i do my old skool:

c:\javac Test.java (to compile)
c:\java Test (to execute)
Exception in thread "main" java.lang.NoClassDefFoundError: Test


is what happens. and like i've said, I can run this in several IDE's and also from the terminal command prompt within linux. I don't know why it refuses to do so in windows since it compiles fine.

Share this post


Link to post
Share on other sites
You can actually set CLASSPATH as an environment variable so you don't have to say it on the command line every time. To do this, go to Control Panel > System > Advanced > Environment Variables, and press New, type CLASSPATH for name, and . for value.

Share this post


Link to post
Share on other sites
^worked

although I'm still baffled by why I'll always have to do that for every thing i run from the command line now... Before i formatted/reinstalled it never hassled me one bit, unless i was creating packages and such. oh well.

Share this post


Link to post
Share on other sites

This topic is 4854 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