LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Why can't I run my Java program on the Ubuntu terminal (https://www.linuxquestions.org/questions/linux-newbie-8/why-cant-i-run-my-java-program-on-the-ubuntu-terminal-929841/)

andrewpw 02-17-2012 02:02 AM

Why can't I run my Java program on the Ubuntu terminal
 
I installed java version 1.6.0_26 on Ubuntu. I can compile my java code, but when I try to run the program using "java Jsh" in the terminal command line, I get this.

Exception in thread "main" java.lang.NoClassDefFoundError: Jsh (wrong name: jsh/Jsh)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

my program compiles and runs fine on eclipse, but won't load on the terminal. I tried a program my professor created on my terminal and it ran fine. Why doesn't mine work. I can post my code if needed. Thanks.

~andrewpw

on.sid 02-17-2012 06:25 AM

I removed Java completely from my system, but I dare guesstimate the following.

1) You need to make sure that the CLASSPATH environment variable holds all locations where the project's class files are to be found.

2) If I remember correctly, Eclipse provides an export function for Java projects packing it together into a .jar file, which you can run with java -jar $file.


All times are GMT -5. The time now is 05:33 PM.