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.
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)
[etc . . .]
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!
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
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'.
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!
http://www.kubuntuforums.net/index.p...&singlepost=96
Hope this helps other newbies!
Comment