Re: JDK Linux installation help!

Discussion in 'Java' started by congo76@gmail.com, Aug 5, 2007.

  1. Guest

    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
    , Aug 5, 2007
    #1
    1. Advertising

  2. ~kurt Guest

    <> 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
    ~kurt, Aug 5, 2007
    #2
    1. Advertising

  3. 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.
    Mike Schilling, Aug 5, 2007
    #3
  4. Lew Guest

    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
    Lew, Aug 5, 2007
    #4
  5. Lew Guest

    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
    Lew, Aug 5, 2007
    #5
  6. Guest

    On Aug 5, 5:25 pm, Lew <> wrote:
    > 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


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


    Congo
    , Aug 7, 2007
    #6
  7. Guest

    On Aug 5, 5:25 pm, Lew <> wrote:
    > 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


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


    Congo
    , Aug 9, 2007
    #7
  8. Guest

    On Aug 8, 11:52 pm, wrote:
    > On Aug 5, 5:25 pm, Lew <> wrote:
    >
    > > 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 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
    , Aug 9, 2007
    #8
  9. Nigel Wade Guest

    wrote:

    > On Aug 8, 11:52 pm, wrote:
    >> On Aug 5, 5:25 pm, Lew <> wrote:
    >>
    >> > 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 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/05/31/howto-sun-java-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
    Nigel Wade, Aug 9, 2007
    #9
  10. Alexey Guest

    On Aug 5, 4:27 pm, "Mike Schilling" <>
    wrote:
    > 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.
    Alexey, Aug 9, 2007
    #10
  11. Guest

    On Aug 9, 4:20 pm, Alexey <> wrote:
    > On Aug 5, 4:27 pm, "Mike Schilling" <>
    > wrote:
    >
    >
    >
    > > wrote:
    > > > Hello,

    >
    > > > I'm pulling my hair out with the SunJDKinstallation 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 recentJDK, 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 theJDKyou ust installed, so it
    > > can't read the class files that theJDKproduces.

    >
    > > You should be able to verify this using "which" (or "whence"). Just ensure
    > > that the java executable you're running comes from theJDK(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.


    Thanks to Nigel and Alexey!

    Alexey, yes I did install 1.6.0 and I have discovered that through my
    own debacles I was running the GNU Java that comes with Fedora. Really
    screwed things up.

    Nigel, fantastic website, haven't gotten it fixed yet but am making
    the corrections because of the libodbc.so and mkfontdir errors. Will
    post when I have succeeded. Basically I seem to be headed in the right
    direction,

    Congo
    , Aug 10, 2007
    #11
  12. Steve Sobol Guest

    On 2007-08-10, <> wrote:

    > Alexey, yes I did install 1.6.0 and I have discovered that through my
    > own debacles I was running the GNU Java that comes with Fedora. Really
    > screwed things up.


    Yes, I use Ubuntu on the desktop and CentOS on the servers I maintain, and
    both install GNU Classpath. They can't ship Sun's JRE due to licensing issues.

    I uninstalled the GNU stuff on my personal CentOS server and installed a Sun
    JDK, but uninstalling GNU's runtime means I also have to install Ubuntu's
    stock OpenOffice.org packages, and I need OOo to do my daily work... I am
    probably going to uninstall the GNU stuff anyhow, but I have to assess how much
    extra work will be required...
    Steve Sobol, Aug 10, 2007
    #12
  13. On Aug 10, 7:07 am, Steve Sobol <>
    > Yes, I use Ubuntu on the desktop and CentOS on the servers I maintain, and
    > both install GNU Classpath. They can't ship Sun's JRE due to licensing issues.


    Sun changed that with a special Distributor License for Java (DLJ)
    this spring. Ubuntu was one of the first ones to make use of this
    license.

    Search for sun-java in synaptic. Install what you want. After
    installation run update-java-alternatives as root to select the
    default Java version in case you have multiple ones installed. E.g.
    GNU and Sun Java 5 and 6.

    List all installed Java alternatives:

    update-java-alternatives -l

    Select one alternative

    update-java-alternatives -s <name as given by -l>

    > I uninstalled the GNU stuff on my personal CentOS server and installed a Sun
    > JDK, but uninstalling GNU's runtime means I also have to install Ubuntu's
    > stock OpenOffice.org packages, and I need OOo to do my daily work... I am
    > probably going to uninstall the GNU stuff anyhow, but I have to assess how much
    > extra work will be required...


    No need to uninstall anything.
    Hunter Gratzner, Aug 10, 2007
    #13
  14. Steve Sobol Guest

    On 2007-08-10, Hunter Gratzner <> wrote:
    > On Aug 10, 7:07 am, Steve Sobol <>
    >> Yes, I use Ubuntu on the desktop and CentOS on the servers I maintain, and
    >> both install GNU Classpath. They can't ship Sun's JRE due to licensing issues.

    >
    > Sun changed that with a special Distributor License for Java (DLJ)
    > this spring. Ubuntu was one of the first ones to make use of this
    > license.
    >
    > Search for sun-java in synaptic. Install what you want. After
    > installation run update-java-alternatives as root to select the
    > default Java version in case you have multiple ones installed. E.g.
    > GNU and Sun Java 5 and 6.


    AAAAAHHHHHHHHH, thank you!

    I have absolutely nothing against GNU, in fact I use GNU software all
    the time, but I'd prefer to run Sun's Java VM. And I knew the Sun
    packages were available because I've checked Synaptic, but I didn't
    know I could change the default JRE.
    Steve Sobol, Aug 10, 2007
    #14
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Babar
    Replies:
    1
    Views:
    432
    Chris Smith
    May 20, 2004
  2. Thomas G. Marshall
    Replies:
    5
    Views:
    800
    Thomas G. Marshall
    Aug 6, 2004
  3. Michele Damian

    Linux jdk installation

    Michele Damian, Mar 28, 2006, in forum: Java
    Replies:
    12
    Views:
    865
    Roedy Green
    Mar 29, 2006
  4. Ulf Meinhardt
    Replies:
    0
    Views:
    6,418
    Ulf Meinhardt
    Aug 10, 2006
  5. Jaggu
    Replies:
    3
    Views:
    985
    Nigel Wade
    Jan 8, 2007
Loading...

Share This Page