Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Using Eclipse I have created a SWT Hello World program. I was able to run this program from Eclipse and it worked fine.

In the "/home/myname/workspace/HelloWorldSWT" I found two files: HelloWorldSWT.java and HelloWorldSWT.class. I wanted to execute the corresponding program from the command line. First I tried to type "java HelloWorld" and I got the following error message:

Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
   at gnu.java.lang.MainThread.run(libgcj.so.90)
Caused by: java.lang.ClassNotFoundException: HelloWorld not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:./], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
   at java.net.URLClassLoader.findClass(libgcj.so.90)
   at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.90)
   at java.lang.ClassLoader.loadClass(libgcj.so.90)
   at java.lang.ClassLoader.loadClass(libgcj.so.90)
   at gnu.java.lang.MainThread.run(libgcj.so.90)

I also tried this "java -cp /home/roman/workspace/ HelloWorld.HelloWorld". As the result I got the following error message:

Exception in thread "main" java.lang.NoClassDefFoundError: loaded class HelloWorld.HelloWorld was in fact named HelloWorld
   at java.lang.VMClassLoader.defineClass(libgcj.so.90)
   at java.lang.ClassLoader.defineClass(libgcj.so.90)
   at java.security.SecureClassLoader.defineClass(libgcj.so.90)
   at java.net.URLClassLoader.findClass(libgcj.so.90)
   at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.90)
   at java.lang.ClassLoader.loadClass(libgcj.so.90)
   at java.lang.ClassLoader.loadClass(libgcj.so.90)
   at gnu.java.lang.MainThread.run(libgcj.so.90)

Does anybody know what I am doing wrong? Thank you in advance for any help.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
153 views
Welcome To Ask or Share your Answers For Others

1 Answer

Go to the Debug perspective, and select the program you just ran (where it says Terminated, exit value... in the Debug tab) Right click, and choose Properties, there you can see the whole command line command that was launched by eclipse.

You can run this same command in the same directory eclipse did (see in Run Configurations, Arguments, Working directory) and it will work.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...