Link to home
Start Free TrialLog in
Avatar of Jason Yu
Jason YuFlag for United States of America

asked on

Java apps couldn't run on Linux OS

I have a server hosting some java applications to send invoices out to our customers. Last week, there was a server file system issue which bought down the server. After I reboot it and did a fscheck it was back to normal. But today we found all our java apps are not working anymore. We used a test app to test, the output was as below. Please advise how to address this, thank you.


[root@luna pdfprc]# java Helloworld.
Exception in thread "main" java.lang.NoClassDefFoundError: Helloworld.
   at gnu.java.lang.MainThread.run(libgcj.so.7rh)
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.7rh)
   at java.lang.ClassLoader.loadClass(libgcj.so.7rh)
   at java.lang.ClassLoader.loadClass(libgcj.so.7rh)
   at gnu.java.lang.MainThread.run(libgcj.so.7rh)
[root@luna pdfprc]#
Avatar of farzanj
farzanj
Flag of Canada image

Please remove dot after helloworld

java Helloworld.

to
java Helloworld
Avatar of Jason Yu

ASKER

Still the same:

[root@luna pdfprc]# java Helloworld
Exception in thread "main" java.lang.ClassFormatError: Helloworld (unrecognized class file version)
   at java.lang.VMClassLoader.defineClass(libgcj.so.7rh)
   at java.lang.ClassLoader.defineClass(libgcj.so.7rh)
   at java.security.SecureClassLoader.defineClass(libgcj.so.7rh)
   at java.net.URLClassLoader.findClass(libgcj.so.7rh)
   at java.lang.ClassLoader.loadClass(libgcj.so.7rh)
   at java.lang.ClassLoader.loadClass(libgcj.so.7rh)
   at gnu.java.lang.MainThread.run(libgcj.so.7rh)
[root@luna pdfprc]#
Java -version

Which Linux distribution do you have?

You need to verify the installed packages for java,
[root@luna pdfprc]# java -version
java version "1.4.2"
gij (GNU libgcj) version 4.1.2 20080704 (Red Hat 4.1.2-51)

Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[root@luna pdfprc]#



[root@luna pdfprc]# cat /etc/*-release
Red Hat Enterprise Linux Server release 5.7 (Tikanga)
[root@luna pdfprc]#


How to verify the installed packages for java?

[root@luna pdfprc]# rpm -qa | grep java
sun-javadb-demo-10.5.3-0.2
sun-javadb-common-10.5.3-0.2
ibm-java-x86_64-sdk-6.0-8.1
sun-javadb-core-10.5.3-0.2
sun-javadb-javadoc-10.5.3-0.2
sun-javadb-client-10.5.3-0.2
java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
sun-javadb-docs-10.5.3-0.2
[root@luna pdfprc]#
You need to compare the versions:

javac -version
java -version
Hi, Farzanj, thank you for your follow up, here are the outputs from your suggested commands.

[root@luna pdfprc]# javac -version
javac 1.6.0_23
[root@luna pdfprc]# java -version
java version "1.4.2"
gij (GNU libgcj) version 4.1.2 20080704 (Red Hat 4.1.2-51)

Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[root@luna pdfprc]#


what is the difference between these two commands?

thanks a lot. This is one of the most important servers in our production environment, I really appreciate your help.
Well, javac is your compiler.  You are generating the byte code for Java 1.6 (java 6).  
java is your Java virtual machine to run your byte code.  It is Java 1.4.

You need to upgrade your java JRE.

You need to install jre-6 package.
Now you can install using a graphical package installer or you can install using command line.

JRE packages also come by different vendors.

issue command

rpm -qa | grep jre
Depending upon the output of the above command you would issue command like

yum install sun-java6-jre

Or

yum update jre

Or something else.
[root@luna pdfprc]# rpm -qa | grep jre
[root@luna pdfprc]#
according to our developer, he said the jre 1.6 has already been installed. but it's not the default. here is the email from him about the path of jre1.6. Could you check it for me?

Since I have IBM's Gentran software installed on this host, it uses Java/Jre too, if I upgrade the version, will it affect the running Gentran software?


Jason,

PATH=.:/usr/java/jdk1.6.0_23/bin:$PATH:$HOME/bin
export PATH

CLASSPATH=.:/usr/java/jdk1.6.0_23/jre/lib/ct.sym
CLASSPATH=$CLASSPATH:/usr/java/jdk1.6.0_23/jre/lib/ext/
CLASSPATH=$CLASSPATH:/u1/home/pdfprc/lib/edtftpj-1.5.5/lib/edtftpj.jar
CLASSPATH=$CLASSPATH:/u1/home/pdfprc/lib/javamail-1.4.1/mail.jar
CLASSPATH=$CLASSPATH:/u1/home/pdfprc/lib/classes12.zip
export CLASSPATH


Sincerely yours
 
David Wu
Alpha and Omega Computer Corp
It doesn't appear to be saving path for JRE, just JDK.

Please issue command for me.

which java


Also

find /usr/java/jdk1.6.0_23/ -name java
[root@luna pdfprc]# which java
/usr/bin/java
[root@luna pdfprc]#



[root@luna pdfprc]# find /usr/java/jdk1.6.0_23/ -name java
/usr/java/jdk1.6.0_23/jre/bin/java
/usr/java/jdk1.6.0_23/java
/usr/java/jdk1.6.0_23/bin/java
[root@luna pdfprc]#
ASKER CERTIFIED SOLUTION
Avatar of farzanj
farzanj
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
[root@luna pdfprc]# /usr/java/jdk1.6.0_23/bin/java -version
java version "1.6.0_23"
Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
Java HotSpot(TM) 64-Bit Server VM (build 19.0-b09, mixed mode)
[root@luna pdfprc]#
That is great, it works now. After I ran the "alias" command, the test java app works now.

I echoed this path to bash profile and I think it was not input to this profile before which caused this error after server reboot.

Thank you very much,farzanj, you did great help to me, I am glad I have an expert here to be my life saver. I really can't say my mode in words, just too excited.

Great job, i will keep using and supporting experts-exchange community.
Very decent job, a real expert at Java field.
Glad to help.  Nice to be appreciated especially at EE where I rarely get any appreciation for my volunteer work.