LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 11-27-2008, 09:05 PM   #1
yuubouna
LQ Newbie
 
Registered: Jan 2007
Posts: 10

Rep: Reputation: 1
Question unrecognized class file version : when running simple Java program


1) I cannot run Simple Java program in Linux.
After executing
javac HelloWorldApp.java
HelloWorldApp.class is created, but when I try to run

java HelloWorldApp
the following error occured:
------------
javac HelloWorldApp.java
Exception in thread "main" java.lang.ClassFormatError: poi.HelloWorldApp (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)
------------


I thought the java version is the case, so I create symbolic link to changed the java version,to points from /usr/local/java to /jdk1.6.0_10 (Am I correct with this one?):
------------
ln -s /usr/local/java /usr/local/jdk1.6.0_10
------------


2) Then running:
java -version

RESULTS TO:
------------
java version "1.4.2"
gij (GNU libgcj) version 4.1.2 20071124 (Red Hat 4.1.2-42)

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.
------------

and
javac -version

RESULTS TO:
------------
javac 1.6.0_10
------------

but It doesn`t solved my problem, anyhow.

3) How to permanently set the path, Java_home, classpath in order to points out to the my new jdk version?

-Does the javac and java version must agree with their version?
-Is the "unrecognized class file version" error is because of java version?

Any help is appreciated.

Cheers,
jackie

Last edited by yuubouna; 11-27-2008 at 09:13 PM.
 
Old 11-27-2008, 11:25 PM   #2
yuubouna
LQ Newbie
 
Registered: Jan 2007
Posts: 10

Original Poster
Rep: Reputation: 1
I solved it!

The reason why I cannot run is, my java and javac version do not agree with each other.
To set up a Java_home permanently, I add the following to [.bash_profile]
If you cannot see the .bash_profile
ls -al - will show all the hidden files.

----------------
.bash_profile
----------------
export JAVA_HOME=/usr/local/jdk1.6.0_10
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib


Now my java, javac version agree with each other.
they are both: jdk1.6.0_10


----------------
Another thing is, When running Java program with Package directory,
Is the same concept when Running Java program in DOS env.
----------------
$ javac poi/impl/HelloWorld.java
$ java poi.impl.HelloWorld
Hello World!

this thread, helps me out, ;-)

Cheers!
jackie
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to run .class java file? rabbit2345 Programming 2 01-24-2008 10:43 AM
Program defined class--Java Fredstar Programming 3 02-28-2006 04:07 PM
java This.class error when running Fredstar Programming 2 02-12-2006 11:48 PM
Running a Java executable class from another executable class LUB997 Programming 22 07-24-2005 04:57 AM
Running Java Class Files hackersapien Programming 9 08-07-2003 06:42 AM


All times are GMT -5. The time now is 04:30 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration