Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Re: JDK Linux installation help!

Reply
Thread Tools

Re: JDK Linux installation help!

 
 
congo76@gmail.com
Guest
Posts: n/a
 
      08-05-2007
Hello,

I'm pulling my hair out with the Sun JDK installation on Fedora 7.
Recently, I decided to explore java and downloaded their product,
followed all the directions (used the rpm.bin installation since I'm
to lazy to compile softaware). Downloaded their "HelloWorld" app and
tried to run it and am getting the apparently very common error below:
(did javac HelloWorld.java 1st to creat the HelloWorld.class file)

[congo@localhost java]$ java HelloWorldApp
Exception in thread "main" java.lang.ClassFormatError: HelloWorldApp
(unrecognized class file version)
at java.lang.VMClassLoader.defineClass(libgcj.so.8rh)
at java.lang.ClassLoader.defineClass(libgcj.so.8rh)
at java.security.SecureClassLoader.defineClass(libgcj .so.8rh)
at java.net.URLClassLoader.findClass(libgcj.so.8rh)
at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj .so.8rh)
at java.lang.ClassLoader.loadClass(libgcj.so.8rh)
at java.lang.ClassLoader.loadClass(libgcj.so.8rh)
at gnu.java.lang.MainThread.run(libgcj.so.8rh)

All documentation on Sun's website and posts I found in this newsgroup
point to updating the CLASSPATH. So I did that in my .bash_profile
file, get the same error. Found the below documentation in the
newsgroup circa 2003:

set JAVA_HOME=/usr/java
set CLASSPATH .;/usr/java/jdk1.6.0_02
export JAVA_HOME CLASSPATH

Did this as root thinking I'd be smart and set the CLASSPATH system
wide even though I'm the only user. At the bottom of that 2003 thread
another guy said that CLASSPATH hasn't been used for years and that I
should just set the PATH in /etc/profile. That's when I stopped and
posted this message. There's a lot of great info/help on how to fix
this problem, but it seems to be taking me further and further into
the forest where I am now lost. Can anyone assist?


v\r

Congo

 
Reply With Quote
 
 
 
 
~kurt
Guest
Posts: n/a
 
      08-05-2007
<> wrote:

> set JAVA_HOME=/usr/java


Is Java really in /usr/java? You should check that it is really there.

> set CLASSPATH .;/usr/java/jdk1.6.0_02
> export JAVA_HOME CLASSPATH
>
> Did this as root thinking I'd be smart and set the CLASSPATH system
> wide even though I'm the only user. At the bottom of that 2003 thread


I'm not sure I understand what you mean when you say you did it as
root. If you opened up a shell window, and did the above, it will
only affect that shell. If you were root, set it, and logged out,
you will lose those settings once logging out.

As yourself, echo the JAVA_HOME variable:

echo $JAVA_HOME

to make sure it has been set.

> another guy said that CLASSPATH hasn't been used for years and that I
> should just set the PATH in /etc/profile. That's when I stopped and
> posted this message. There's a lot of great info/help on how to fix
> this problem, but it seems to be taking me further and further into
> the forest where I am now lost. Can anyone assist?


The first step is to echo $JAVA_HOME. It sounds like your $PATH variable
is set since you can call javac with no issues.

Yea, it has been a long time since I have had to set CLASSPATH to get
Java to work. I only set it so Java can find external packages.

I also haven't manually set up Java on Linux in years - the installation
package does it all for me now days. The global environmental variables set
for everyone are in /etc/profile.d for my distro:

export JAVA_HOME=/usr/lib/java
export MANPATH="$MANPATH:/usr/lib/java/man"
export PATH="$PATH:/usr/lib/java/bin:/usr/lib/java/jre/bin"

- Kurt
 
Reply With Quote
 
 
 
 
Mike Schilling
Guest
Posts: n/a
 
      08-05-2007
wrote:
> Hello,
>
> I'm pulling my hair out with the Sun JDK installation on Fedora 7.
> Recently, I decided to explore java and downloaded their product,
> followed all the directions (used the rpm.bin installation since I'm
> to lazy to compile softaware). Downloaded their "HelloWorld" app and
> tried to run it and am getting the apparently very common error below:
> (did javac HelloWorld.java 1st to creat the HelloWorld.class file)
>
> [congo@localhost java]$ java HelloWorldApp
> Exception in thread "main" java.lang.ClassFormatError: HelloWorldApp
> (unrecognized class file version)
> at java.lang.VMClassLoader.defineClass(libgcj.so.8rh)
> at java.lang.ClassLoader.defineClass(libgcj.so.8rh)> at
> java.lang.ClassLoader.loadClass(libgcj.so.8rh)
> at gnu.java.lang.MainThread.run(libgcj.so.8rh)
>
> All documentation on Sun's website and posts I found in this newsgroup
> at java.security.SecureClassLoader.defineClass(libgcj .so.8rh)
> at java.net.URLClassLoader.findClass(libgcj.so.8rh)
> at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj .so.8rh)
> at java.lang.ClassLoader.loadClass(libgcj.so.8rh)


> point to updating the CLASSPATH. So I did that in my .bash_profile
> file, get the same error. Found the below documentation in the
> newsgroup circa 2003:
>
> set JAVA_HOME=/usr/java
> set CLASSPATH .;/usr/java/jdk1.6.0_02
> export JAVA_HOME CLASSPATH
>
> Did this as root thinking I'd be smart and set the CLASSPATH system
> wide even though I'm the only user. At the bottom of that 2003 thread
> another guy said that CLASSPATH hasn't been used for years and that I
> should just set the PATH in /etc/profile. That's when I stopped and
> posted this message. There's a lot of great info/help on how to fix
> this problem, but it seems to be taking me further and further into
> the forest where I am now lost. Can anyone assist?


My guess is the following:

You installed a recent JDK, and that's where you're running javac from.
There was already a JRE on the machine, and that's where you're running java
from. This JRE is an older version than the JDK you ust installed, so it
can't read the class files that the JDK produces.

You should be able to verify this using "which" (or "whence"). Just ensure
that the java executable you're running comes from the JDK (i.e. from the
same bin directory thata javac lives in), and you shouild be fine.


 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      08-05-2007
wrote:
>> point to updating the CLASSPATH. So I did that in my .bash_profile
>> file, get the same error. Found the below documentation in the
>> newsgroup circa 2003:
>>
>> set JAVA_HOME=/usr/java
>> set CLASSPATH .;/usr/java/jdk1.6.0_02
>> export JAVA_HOME CLASSPATH
>>
>> Did this as root thinking I'd be smart and set the CLASSPATH system
>> wide even though I'm the only user. At the bottom of that 2003 thread
>> another guy said that CLASSPATH hasn't been used for years and that I
>> should just set the PATH in /etc/profile. That's when I stopped and
>> posted this message. There's a lot of great info/help on how to fix
>> this problem, but it seems to be taking me further and further into
>> the forest where I am now lost. Can anyone assist?


CLASSPATH and PATH are two entirely different things. One roots the search
for Java .class files, the other for Linux executables.

The .bash_profile script you show is not bash. Maybe it's csh?

Paths in Linux (UNIX) are separated by colons, not semicolons. Furthermore,
it's usually better not to set CLASSPATH as it obscures what is going on.
Instead, use the "-cp" (same effect as "-classpath") option to the java
command (or the corresponding Ant target).

Furthermore, /usr/java/jdk1.6.0_02/ is not the root of any class path, so even
if you do have a CLASSPATH you wouldn't include that path element.

Your profile should look more like:

export JAVA_HOME=/usr/java
# export CLASSPATH=.
# the default CLASSPATH is the current working directory anyway

These are better placed in /etc/profile than in a user profile.

Another choice is to use the Linux "alternatives" mechanism to allow multiple
Java versions to coexist peacefully.

--
Lew
 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      08-05-2007
wrote:
>> set JAVA_HOME=/usr/java


~kurt wrote:
> Is Java really in /usr/java? You should check that it is really there.


wrote:
>> set CLASSPATH .;/usr/java/jdk1.6.0_02


You installed your JDK into /usr/java/jdk1.6.0_02/, right? That's JAVA_HOME.

--
Lew
 
Reply With Quote
 
congo76@gmail.com
Guest
Posts: n/a
 
      08-07-2007
On Aug 5, 5:25 pm, Lew <l...@lewscanon.nospam> wrote:
> cong...@gmail.com wrote:
> >> set JAVA_HOME=/usr/java

> ~kurt wrote:
> > Is Java really in /usr/java? You should check that it is really there.

> cong...@gmail.com wrote:
> >> set CLASSPATH .;/usr/java/jdk1.6.0_02

>
> You installed your JDK into /usr/java/jdk1.6.0_02/, right? That's JAVA_HOME.
>
> --
> Lew


Thanks to all of you for responding so quickly, I'll give it a shot
and see what happens,


Congo


 
Reply With Quote
 
congo76@gmail.com
Guest
Posts: n/a
 
      08-09-2007
On Aug 5, 5:25 pm, Lew <l...@lewscanon.nospam> wrote:
> cong...@gmail.com wrote:
> >> set JAVA_HOME=/usr/java

> ~kurt wrote:
> > Is Java really in /usr/java? You should check that it is really there.

> cong...@gmail.com wrote:
> >> set CLASSPATH .;/usr/java/jdk1.6.0_02

>
> You installed your JDK into /usr/java/jdk1.6.0_02/, right? That's JAVA_HOME.
>
> --
> Lew


Yes I did install it in this directory, still having problems. Have
busted java in Mozilla now as well,


Congo

 
Reply With Quote
 
congo76@gmail.com
Guest
Posts: n/a
 
      08-09-2007
On Aug 8, 11:52 pm, cong...@gmail.com wrote:
> On Aug 5, 5:25 pm, Lew <l...@lewscanon.nospam> wrote:
>
> > cong...@gmail.com wrote:
> > >> set JAVA_HOME=/usr/java

> > ~kurt wrote:
> > > Is Java really in /usr/java? You should check that it is really there.

> > cong...@gmail.com wrote:
> > >> set CLASSPATH .;/usr/java/jdk1.6.0_02

>
> > You installed yourJDKinto /usr/java/jdk1.6.0_02/, right? That's JAVA_HOME.

>
> > --
> > Lew

>
> Yes I did install it in this directory, still having problems. Have
> busted java in Mozilla now as well,
>
> Congo

Ok, it's official, I'm completely lost. Nothing I do is working. From
what I think I know, Fedora 7 must come with an installation of Java,
by me installing the JDK & JRE packages from Sun, I've confused my
system/me as to how to use Java. I've followed the advise here as well
as re-read Sun's documentation and nothing is producing results. I
guess I don't understand what I'm not understanding,

Congo

 
Reply With Quote
 
Nigel Wade
Guest
Posts: n/a
 
      08-09-2007
wrote:

> On Aug 8, 11:52 pm, cong...@gmail.com wrote:
>> On Aug 5, 5:25 pm, Lew <l...@lewscanon.nospam> wrote:
>>
>> > cong...@gmail.com wrote:
>> > >> set JAVA_HOME=/usr/java
>> > ~kurt wrote:
>> > > Is Java really in /usr/java? You should check that it is really there.
>> > cong...@gmail.com wrote:
>> > >> set CLASSPATH .;/usr/java/jdk1.6.0_02

>>
>> > You installed yourJDKinto /usr/java/jdk1.6.0_02/, right? That's

JAVA_HOME.
>>
>> > --
>> > Lew

>>
>> Yes I did install it in this directory, still having problems. Have
>> busted java in Mozilla now as well,
>>
>> Congo

> Ok, it's official, I'm completely lost. Nothing I do is working. From
> what I think I know, Fedora 7 must come with an installation of Java,


It comes with a "Java" installation of sorts, whether you choose to call it Java
is moot. The Fedora packagers are a tad retentive about *everything* having to
be FOSS so won't ship Sun Java even if it makes their distro. worse for it.
Whatever you do, do not enable the gcj browser plugin (gcjwebplugin) - AFAIK it
still has no sandbox, and even if it does I wouldn't trust it yet.

> by me installing the JDK & JRE packages from Sun, I've confused my
> system/me as to how to use Java.


Yep, that is quite a normal state for users of Java on Fedora.

> I've followed the advise here as well
> as re-read Sun's documentation and nothing is producing results.


Unfortunately Sun cannot take account of the idiosyncrasies (and idiocies) of
each and every Linux distro. They provide a binary installer which just unpacks
the JDK into a directory and leaves the rest up to you, that is often the best
option. They also provide some packaged installers for some distros, which
unfortunately have side effects in some cases. Fedora being a prime example.

See:
http://liquidat.wordpress.com/2007/0...a-on-fedora-7/
http://fedoraproject.org/wiki/JavaFAQ.

--
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail :
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555
 
Reply With Quote
 
Alexey
Guest
Posts: n/a
 
      08-09-2007
On Aug 5, 4:27 pm, "Mike Schilling" <mscottschill...@hotmail.com>
wrote:
> cong...@gmail.com wrote:
> > Hello,

>
> > I'm pulling my hair out with the Sun JDK installation on Fedora 7.
> > Recently, I decided to explore java and downloaded their product,
> > followed all the directions (used the rpm.bin installation since I'm
> > to lazy to compile softaware). Downloaded their "HelloWorld" app and
> > tried to run it and am getting the apparently very common error below:
> > (did javac HelloWorld.java 1st to creat the HelloWorld.class file)

>
> > [congo@localhost java]$ java HelloWorldApp
> > Exception in thread "main" java.lang.ClassFormatError: HelloWorldApp
> > (unrecognized class file version)
> > at java.lang.VMClassLoader.defineClass(libgcj.so.8rh)
> > at java.lang.ClassLoader.defineClass(libgcj.so.8rh)> at
> > java.lang.ClassLoader.loadClass(libgcj.so.8rh)
> > at gnu.java.lang.MainThread.run(libgcj.so.8rh)

>
> > All documentation on Sun's website and posts I found in this newsgroup
> > at java.security.SecureClassLoader.defineClass(libgcj .so.8rh)
> > at java.net.URLClassLoader.findClass(libgcj.so.8rh)
> > at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj .so.8rh)
> > at java.lang.ClassLoader.loadClass(libgcj.so.8rh)
> > point to updating the CLASSPATH. So I did that in my .bash_profile
> > file, get the same error. Found the below documentation in the
> > newsgroup circa 2003:

>
> > set JAVA_HOME=/usr/java
> > set CLASSPATH .;/usr/java/jdk1.6.0_02
> > export JAVA_HOME CLASSPATH

>
> > Did this as root thinking I'd be smart and set the CLASSPATH system
> > wide even though I'm the only user. At the bottom of that 2003 thread
> > another guy said that CLASSPATH hasn't been used for years and that I
> > should just set the PATH in /etc/profile. That's when I stopped and
> > posted this message. There's a lot of great info/help on how to fix
> > this problem, but it seems to be taking me further and further into
> > the forest where I am now lost. Can anyone assist?

>
> My guess is the following:
>
> You installed a recent JDK, and that's where you're running javac from.
> There was already a JRE on the machine, and that's where you're running java
> from. This JRE is an older version than the JDK you ust installed, so it
> can't read the class files that the JDK produces.
>
> You should be able to verify this using "which" (or "whence"). Just ensure
> that the java executable you're running comes from the JDK (i.e. from the
> same bin directory thata javac lives in), and you shouild be fine.


I think this person is onto something. Sometimes it's possible to get
yourself into a bind when there is a preceding JRE before you install
the one you really want. A few things I'd do in your situation:

which -a java
which -a javac
echo $PATH
java -version

The stacktrace you're getting appears to indicate a version problem
(class files being of a later spec version than what the JVM is able
to run). From what you've said, I gather your current install is
version 1.6.0, which as of now should be able to handle any class
specification. That tells me that when you invoke "java", you're
actually running an older JVM. This could be due to your PATH
pointing to some Fedora's own older JVM perhaps or something that was
on that system previously, maybe a JVM that came with a browser.
Either way, outputting your PATH will let you know how the system is
searching for that executable. "which -a" will tell you all the java
executables it's finding now. Maybe your JAVA_HOME is not being used
as part of PATH. Maybe it's being obscured by this older JVM ghost.

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
regarding JDk 141 and JDK 122 for linux 64 bit Platform Jaggu Java 3 01-08-2007 10:47 AM
What is the difference between J2EE, JDK, JDK-SDK, JRE and J2SE packages ? Ulf Meinhardt Java 0 08-10-2006 07:12 PM
Linux jdk installation Michele Damian Java 12 03-29-2006 09:02 PM
jEdit: compiles JDK 1.5.0 ok, but runs JDK 1.4.1 (why?) Thomas G. Marshall Java 5 08-06-2004 04:12 AM
Help with converting IDS from JDK 1.1 to JDK 1.4 Babar Java 1 05-20-2004 09:11 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57