Maybe this could belong in the beginner forum, but I'm not sure - since it contains sockets and what not. Anyhow, I am working on a server for a little project I am doing. I made a skeleton of it that sends messages from the client back. Of course, when I get it working I will take that out and add some functionality. It compiled fine and dandy in Netbeans, but when I try to run it via 'java.exe', I get 'Exception in thread "main" java.lang.NoClassDefFoundError'. I researched it a bit but still couldn't find the problem. Thus, I'm here asking for help.
Edit: I just re-read your post and saw that you were not running it through the netbeans IDE, so that changes my answer. Make sure that server1.class is in your classpath (try running it and fully qualifying the location of server1.class, ie "java.exe C:\java stuff\server program\server1".
I tried running it using my IDE and it worked fine. I *just* found out right now that NetBeans runs all programs in a certain directory (netbeans/bin) so perhaps this is messing it up? Check out the post here. Also, you could try running it simply using "java server1" when server1.class is in your java classpath. Good luck. [ February 08, 2004: Message edited by: Donny Nadolny ]
- Donny Nadolny<br />The pen is mightier than the sword, and considerably easier to write with.
Donny -- You can't run a Java class by specifying the full path to the .class file. The argument to "java.exe" is the name of a class -- not a filesystem path. You probably both should read the JavaRanch guide to CLASSPATHs. I'm moving this to the Beginner's Forum.
Hi i have read ur code, but the problem which u have asked for is not related to the code of the program the problem is with the setting of the environment variables of ur Operating System. If u are using Windows OS than just include the path of the output directory and the source directory both in the CLASS PATH environment variable of autoexec.bat and than restart ur system. i hope that it works fine after
Joined: Feb 07, 2004
Ah, okay. I was thinking that you didn't have to worry about CLASSPATH if you specified a full path. But I guess I was wrong. Thanks for all the help