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]#
Jason YuAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

farzanjCommented:
Please remove dot after helloworld

java Helloworld.

to
java Helloworld
0
Jason YuAuthor Commented:
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]#
0
arnoldCommented:
Java -version

Which Linux distribution do you have?

You need to verify the installed packages for java,
0
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

Jason YuAuthor Commented:
[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]#
0
farzanjCommented:
You need to compare the versions:

javac -version
java -version
0
Jason YuAuthor Commented:
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.
0
farzanjCommented:
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.
0
farzanjCommented:
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
0
farzanjCommented:
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.
0
Jason YuAuthor Commented:
[root@luna pdfprc]# rpm -qa | grep jre
[root@luna pdfprc]#
0
Jason YuAuthor Commented:
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
0
farzanjCommented:
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
0
Jason YuAuthor Commented:
[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]#
0
farzanjCommented:
Issue this command and see if it works.

/usr/java/jdk1.6.0_23/bin/java -version
If this is the right version, issue this command

alias java='/usr/java/jdk1.6.0_23/bin/java'

To make it permanent

echo "alias java='/usr/java/jdk1.6.0_23/bin/java'" >> ~/.bash_profile

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jason YuAuthor Commented:
[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]#
0
Jason YuAuthor Commented:
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.
0
Jason YuAuthor Commented:
Very decent job, a real expert at Java field.
0
farzanjCommented:
Glad to help.  Nice to be appreciated especially at EE where I rarely get any appreciation for my volunteer work.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.