Jump to content
  • Advertisement
Sign in to follow this  
ippo

[java] Windows - Java - Problems

This topic is 5166 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
Advertisement
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
Older versions of Java automatically set the classpath to include the current directory. I think at v1.3, it changed so you have to have it set even for the current directory.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!