Jason Yu
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.NoClassDefFoundE rror: Helloworld.
at gnu.java.lang.MainThread.r un(libgcj. so.7rh)
Caused by: java.lang.ClassNotFoundExc eption: Helloworld. not found in gnu.gcj.runtime.SystemClas sLoader{ur ls=[file:. /], parent=gnu.gcj.runtime.Ext ensionClas sLoader{ur ls=[], parent=null}}
at java.net.URLClassLoader.fi ndClass(li bgcj.so.7r h)
at java.lang.ClassLoader.load Class(libg cj.so.7rh)
at java.lang.ClassLoader.load Class(libg cj.so.7rh)
at gnu.java.lang.MainThread.r un(libgcj. so.7rh)
[root@luna pdfprc]#
[root@luna pdfprc]# java Helloworld.
Exception in thread "main" java.lang.NoClassDefFoundE
at gnu.java.lang.MainThread.r
Caused by: java.lang.ClassNotFoundExc
at java.net.URLClassLoader.fi
at java.lang.ClassLoader.load
at java.lang.ClassLoader.load
at gnu.java.lang.MainThread.r
[root@luna pdfprc]#
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.de fineClass( libgcj.so. 7rh)
at java.lang.ClassLoader.defi neClass(li bgcj.so.7r h)
at java.security.SecureClassL oader.defi neClass(li bgcj.so.7r h)
at java.net.URLClassLoader.fi ndClass(li bgcj.so.7r h)
at java.lang.ClassLoader.load Class(libg cj.so.7rh)
at java.lang.ClassLoader.load Class(libg cj.so.7rh)
at gnu.java.lang.MainThread.r un(libgcj. so.7rh)
[root@luna pdfprc]#
[root@luna pdfprc]# java Helloworld
Exception in thread "main" java.lang.ClassFormatError
at java.lang.VMClassLoader.de
at java.lang.ClassLoader.defi
at java.security.SecureClassL
at java.net.URLClassLoader.fi
at java.lang.ClassLoader.load
at java.lang.ClassLoader.load
at gnu.java.lang.MainThread.r
[root@luna pdfprc]#
Java -version
Which Linux distribution do you have?
You need to verify the installed packages for java,
Which Linux distribution do you have?
You need to verify the installed packages for java,
ASKER
[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]#
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
ibm-java-x86_64-sdk-6.0-8.
sun-javadb-core-10.5.3-0.2
sun-javadb-javadoc-10.5.3-
sun-javadb-client-10.5.3-0
java-1.4.2-gcj-compat-1.4.
sun-javadb-docs-10.5.3-0.2
[root@luna pdfprc]#
You need to compare the versions:
javac -version
java -version
javac -version
java -version
ASKER
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.
[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.
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
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.
yum install sun-java6-jre
Or
yum update jre
Or something else.
ASKER
[root@luna pdfprc]# rpm -qa | grep jre
[root@luna pdfprc]#
[root@luna pdfprc]#
ASKER
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:$PA TH:$HOME/b in
export PATH
CLASSPATH=.:/usr/java/jdk1 .6.0_23/jr e/lib/ct.s ym
CLASSPATH=$CLASSPATH:/usr/ java/jdk1. 6.0_23/jre /lib/ext/
CLASSPATH=$CLASSPATH:/u1/h ome/pdfprc /lib/edtft pj-1.5.5/l ib/edtftpj .jar
CLASSPATH=$CLASSPATH:/u1/h ome/pdfprc /lib/javam ail-1.4.1/ mail.jar
CLASSPATH=$CLASSPATH:/u1/h ome/pdfprc /lib/class es12.zip
export CLASSPATH
Sincerely yours
David Wu
Alpha and Omega Computer Corp
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_
export PATH
CLASSPATH=.:/usr/java/jdk1
CLASSPATH=$CLASSPATH:/usr/
CLASSPATH=$CLASSPATH:/u1/h
CLASSPATH=$CLASSPATH:/u1/h
CLASSPATH=$CLASSPATH:/u1/h
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
Please issue command for me.
which java
Also
find /usr/java/jdk1.6.0_23/ -name java
ASKER
[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]#
/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/
/usr/java/jdk1.6.0_23/java
/usr/java/jdk1.6.0_23/bin/
[root@luna pdfprc]#
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
[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]#
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]#
ASKER
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.
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.
ASKER
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.
java Helloworld.
to
java Helloworld