Announcement

Collapse
No announcement yet.

Sun JDK and JRE on Kubuntu Feisty [Success story]

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Sun JDK and JRE on Kubuntu Feisty [Success story]

    I hope this is the apropriate forum for this topic, but not sure. I welcome additions from experienced users.

    This gives the abbreviated story of how I got the Sun JRE and JDK working on Kubuntu Feisty Fawn 7.04. Certainly I'm not the first, but this kind of information is gold for a Linux newbie like me.

    Problem: Can't compile and execute simple HelloWorldApp.java

    I can compile HelloWorldApp.java without any errors. When I try to execute it I get the error Exception in thread "main" java.lang.ClassFormatError: HelloWorldApp (unrecognized class file version).

    Apropos

    * https://help.ubuntu.com/6.10/kubuntu...ogramming.html
    * http://java.sun.com/docs/books/tutor...java/unix.html
    * http://ubuntuforums.org/showthread.p...ht=java+feisty
    * http://ubuntuforums.org/showthread.p...t=javac+feisty

    Procedure

    1. Configure sun-java6-bin
    2. Configure sun-java6-sdk
    3. Create simple HelloWorldApp.java from Sun's own site
    4. Compile with no errors
    5. Execute
    6. Observe strange errors, curse and stomp

    Solution

    Use the update-java-alternatives command to set java-6-sun as the JRE for this environment.

    Code:
    sudo update-java-alternatives -l
    sudo update-java-alternatives -s java-6-sun
    http://ubuntuforums.org/showthread.p...t=javac+feisty

    Konsole Log (edited for brevity)

    ken@vfeisty:~$ echo -e '/**
    > * The HelloWorldApp class implements an application that
    > * simply prints "Hello World!" to standard output.
    > */
    > class HelloWorldApp {
    > public static void main(String[] args) {
    > System.out.println("Hello World!"); // Display the string.
    > }
    > }
    > ' > HelloWorldApp.java

    ken@vfeisty:~$ javac HelloWorldApp.java
    ken@vfeisty:~$ java HelloWorldApp
    Exception in thread "main" java.lang.ClassFormatError: HelloWorldApp (unrecognized class file version)
    at java.lang.VMClassLoader.defineClass(libgcj.so.70)
    at java.lang.ClassLoader.defineClass(libgcj.so.70)
    at java.security.SecureClassLoader.defineClass(libgcj .so.70)
    at java.net.URLClassLoader.findClass(libgcj.so.70)
    at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj .so.70)
    at java.lang.ClassLoader.loadClass(libgcj.so.70)
    at java.lang.ClassLoader.loadClass(libgcj.so.70)
    at gnu.java.lang.MainThread.run(libgcj.so.70)

    Code:
    ken@vfeisty:/usr/lib/jvm/java-gcj/jre/bin$ sudo update-java-alternatives -l
    Password:
    java-6-sun 63 /usr/lib/jvm/java-6-sun
    java-gcj 1041 /usr/lib/jvm/java-gcj
    ken@vfeisty:/usr/lib/jvm/java-gcj/jre/bin$ sudo update-java-alternatives -s java-6-sun
    Using `/usr/lib/jvm/java-6-sun/bin/appletviewer' to provide `appletviewer'.
    [etc . . .]

    Code:
    ken@vfeisty:/usr/lib/jvm/java-gcj/jre/bin$ mkdir ~/java && cd ~/java
    ken@vfeisty:~/java$ echo -e '/**
    > * The HelloWorldApp class implements an application that
    > * simply prints "Hello World!" to standard output.
    > */
    > class HelloWorldApp {
    > public static void main(String[] args) {
    > System.out.println("Hello World!"); // Display the string.
    > }
    > }
    > ' > HelloWorldApp.java
    ken@vfeisty:~/java$ javac HelloWorldApp.java
    ken@vfeisty:~/java$ java HelloWorldApp
    Hello World!
    That should be enough, but see this post on my blog if you want more complete details:
    http://www.kubuntuforums.net/index.p...&singlepost=96

    Hope this helps other newbies!
    Welcome newbies!
    Verify the ISO
    Kubuntu's documentation

    #2
    Re: Sun JDK and JRE on Kubuntu Feisty [Success story]

    Just curious, but why did you not want to use the ones in the multiverse repository?

    Comment


      #3
      Re: Sun JDK and JRE on Kubuntu Feisty [Success story]

      Hi Detonate,

      Originally posted by Detonate
      Just curious, but why did you not want to use the ones in the multiverse repository?
      I don't know what you mean by "ones in the multiverse." AFAIK the multiverse repo is enabled, and I can't even guess why apt-get might choose the wrong packages. Please have a look at the blog posting and tell me where I went wrong.

      Code:
      ken@vfeisty:~/old-stuff$ cat /etc/apt/sources.list
      # See [url]http://help.ubuntu.com/community/UpgradeNotes[/url] for how to upgrade to
      # newer versions of the distribution.
      
      deb [url]http://us.archive.ubuntu.com/ubuntu/[/url] feisty main restricted
      deb-src [url]http://us.archive.ubuntu.com/ubuntu/[/url] feisty main restricted
      
      ## Major bug fix updates produced after the final release of the
      ## distribution.
      deb [url]http://us.archive.ubuntu.com/ubuntu/[/url] feisty-updates main restricted
      deb-src [url]http://us.archive.ubuntu.com/ubuntu/[/url] feisty-updates main restricted
      
      ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
      ## team, and may not be under a free licence. Please satisfy yourself as to
      ## your rights to use the software. Also, please note that software in
      ## universe WILL NOT receive any review or updates from the Ubuntu security
      ## team.
      deb [url]http://us.archive.ubuntu.com/ubuntu/[/url] feisty universe
      deb-src [url]http://us.archive.ubuntu.com/ubuntu/[/url] feisty universe
      
      ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
      ## team, and may not be under a free licence. Please satisfy yourself as to
      ## your rights to use the software. Also, please note that software in
      ## multiverse WILL NOT receive any review or updates from the Ubuntu
      ## security team.
      deb [url]http://us.archive.ubuntu.com/ubuntu/[/url] feisty multiverse
      deb-src [url]http://us.archive.ubuntu.com/ubuntu/[/url] feisty multiverse
      
      ## Uncomment the following two lines to add software from the 'backports'
      ## repository.
      ## N.B. software from this repository may not have been tested as
      ## extensively as that contained in the main release, although it includes
      ## newer versions of some applications which may provide useful features.
      ## Also, please note that software in backports WILL NOT receive any review
      ## or updates from the Ubuntu security team.
      # deb [url]http://us.archive.ubuntu.com/ubuntu/[/url] feisty-backports main restricted universe multiverse
      # deb-src [url]http://us.archive.ubuntu.com/ubuntu/[/url] feisty-backports main restricted universe multiverse
      
      deb [url]http://security.ubuntu.com/ubuntu[/url] feisty-security main restricted
      deb-src [url]http://security.ubuntu.com/ubuntu[/url] feisty-security main restricted
      deb [url]http://security.ubuntu.com/ubuntu[/url] feisty-security universe
      deb-src [url]http://security.ubuntu.com/ubuntu[/url] feisty-security universe
      deb [url]http://security.ubuntu.com/ubuntu[/url] feisty-security multiverse
      deb-src [url]http://security.ubuntu.com/ubuntu[/url] feisty-security multiverse
      ken@vfeisty:~/old-stuff$
      Welcome newbies!
      Verify the ISO
      Kubuntu's documentation

      Comment


        #4
        Re: Sun JDK and JRE on Kubuntu Feisty [Success story]

        My mistake. I thought you had installed jdk and jre from source, but I see you installed them with apt-get. Should have read the blog before I posted.

        Comment


          #5
          Re: Sun JDK and JRE on Kubuntu Feisty [Success story]

          That's okay. I'm still finding my way around Kubuntu myself. It's really fun, and I'm learning much.


          Code:
           1. Configure sun-java6-bin
           2. Configure sun-java6-sdk
          Since I did use apt-get to obtain sun-java, am I incorrect in saying "[c]onfigure?"
          Welcome newbies!
          Verify the ISO
          Kubuntu's documentation

          Comment

          Working...
          X