Hi, I'm very new to Java and learning by typing some example code. I've wrote a small class that uses a SWT GUI but I'm getting the following error when I try to run it in the command line (in Eclipse, no probs!) ....
the above error is due to the particular jar or lib file is missing .. open notepad ,copy the content of the program ..save it and run as ordinary java program from command prompt..people like opu should start write coding using notepad..then only u will know about the classes and methods available in java
Joined: Jan 25, 2006
Sorry, I'm not sure what you mean? I should start using Notepad? How does it help me? I'm using Eclipse alot for wrinting ActionScript so I'm not completely unfamiliar with it.
The error looks like some SWT specific stuff is missing but what do I have to do to get this working?
Originally posted by Jesper Young: NoClassDefFoundError means that the Java runtime environment can't find a class that your program needs. In 99.9% of the cases, this means your classpath is incorrect.
You are starting your application with: java -cp . SWTTest So you are only including the current directory (".") in the classpath.
Add the necessary JAR file or directory that contains the SWT classes to your classpath.
Ok, I get what you mean! Now I'm trying it with the following ...
I've also added a . to the CLASSPATH env variable so I don't need the -cp . but it still doesn't work and gives me an error, this time only a java.lang.NoClassDefFoundError. Obviously it's the correct jar file for the SWT classes but something is still wrong. [ April 21, 2006: Message edited by: Sascha Balkau ]
unpack swt.jar to your JRE/lib folder, copy the three swt...dll to your JRE/bin folder (ideally). On the environment variable CLASSPATH add .;path/to/JRE/lib On the environment variable PATH add path/to/JRE/bin (if not already there)
now SWT Java apps should be able to run on the command line by simply using Java YourApp.
... always refreshing that nowhere guides can be found that explain this! :/