LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Error running java (https://www.linuxquestions.org/questions/linux-newbie-8/error-running-java-558018/)

gamor 05-31-2007 10:06 AM

Error running java
 
Hello everyone,
When I am running a java code I get this error

Exception in thread "main" java.lang.NoClassDefFoundError: ml.options.Options
at java.lang.Class.initializeClass(libgcj.so.7)
at ToUnicode.main(ToUnicode.java:34)
Caused by: java.lang.ClassNotFoundException: java.lang.Enum not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:./,file:/home/ghita/Indri/Transliterator/options.jar], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[file:/usr/share/java-ext/bcprov-jdk14-1.35.jar], parent=null}}
at java.net.URLClassLoader.findClass(libgcj.so.7)
at java.lang.ClassLoader.loadClass(libgcj.so.7)
at java.lang.ClassLoader.loadClass(libgcj.so.7)
at java.lang.VMClassLoader.defineClass(libgcj.so.7)
at java.lang.ClassLoader.defineClass(libgcj.so.7)
at java.security.SecureClassLoader.defineClass(libgcj.so.7)
at java.net.URLClassLoader.findClass(libgcj.so.7)
at java.lang.ClassLoader.loadClass(libgcj.so.7)
at java.lang.ClassLoader.loadClass(libgcj.so.7)
at java.lang.Class.forName(libgcj.so.7)
at java.lang.Class.initializeClass(libgcj.so.7)
...1 more
when I type java -version, that's what I get
java version "1.4.2"
gij (GNU libgcj) version 4.1.2 20070302 (prerelease) (4.1.2-1mdv2007.1)

I am not sure if it is the version I am running or something else

thanks for your help

rita

Coldfire 05-31-2007 10:59 PM

java.lang.Enum was not part of Java 1.4 (which is the version your machine says you are running). Uninstall the gcj Java compiler and download Java 1.5 for Linux from the Sun Java site:

http://java.sun.com/javase/downloads/index_jdk5.jsp

You may not need the SDK if you aren't going to compile Java programs. In that case, get the JRE.

You can also go with Java 6:

http://java.sun.com/javase/downloads/index.jsp

Unpack them somewhere in /usr/local (like /usr/local/java)

You'll have to

Code:

export PATH=$PATH:/usr/local/java/bin
export CLASSPATH=$CLASSPATH:/usr/local/java/jre/lib/rt.jar

to run or compile programs.

jay73 05-31-2007 11:22 PM

Well, there actually isn't any real needd to uninstall gcj before installing a jdk. All it does is sae some space. As for the jdk, that should be available straight from your repositories if you use Suse, Debian, Ubuntu, Gentoo, Mandriva, ... (Fedora, CentOS and Slackware are exceptions in this case - these do force you to get and install the jdk yourself).

Coldfire 06-01-2007 12:56 AM

I suggested the uninstall and the download from Sun because I have never had anything but problems otherwise. I guess I get picky-I do most development in Java, and I don't like it when things screw with my Java environment.

jay73 06-01-2007 01:50 AM

By using update-alternatives, you can simply switch from gcj to jdk5 or jdk6 and back. It works fine for me. Tomcat 5.5? I switch to jdk5. Tomcat 6? OK, then I use jdk6. Of course, you need to remember what was compiled on which of those three - things could get messy if you don't. From that viewpoint, keeping only one isn't a bad idea at all - but unfortunately there are still plenty of JSP frameworks that won't run with JDK6.


All times are GMT -5. The time now is 12:11 AM.