ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I recommend getting it from Sun's Java page and click on Java SE on the right-hand side, and it'll take you to a page with different Java SE "bundles"...for everyday Java, scroll down the list, and look for "JDK 5.0 Update 9" (it's the fourth item down), and then get the "Linux self-extracting file" (jdk-1_5_0_09-linux-i586.bin). Installation instructions are here.
When you run the binary installer (don't forget to "chmod +x jdk-1_5_0_09-linux-i586.bin", and run, as root), it will install to "/usr/java/jdk1.5.0_09/". (at least, that's where it went, by default, for me)
If you are using Sun's J2SE JDK, just try removing it, and reinstalling it.
Hello again, M$ISBS! If things still aren't working for you, please try this:
Quote:
1. If you haven't already done so, please download and install the Sun JDK per these instructions: http://java.sun.com/j2se/1.5.0/install-linux.html
Please post back if you have any problems or questions
<= IT SOUNDS LIKE THIS IS ALREADY DONE AND WORKING
2. Go to your "working directory"
EXAMPLE:
mkdir ~/work
cd ~/work
3. Create your "hello world". Let's just call it "hello.java" this time:
vi hello.java
Code:
public class hello {
public static void main (String[] args) {
System.out.println ("hello java!");
}
}
4. Compile it and verify you got a class file:
Quote:
javac -version hello.java
javac 1.5.0_07
Quote:
ls -l
total 8
-rw-r--r-- 1 paulsm users 415 2006-11-24 10:41 hello.class
-rw-r--r-- 1 paulsm users 112 2006-11-24 10:41 hello.java
5. Make sure the Java runtime version matches your compiler version:
Quote:
java -version
java version "1.5.0_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-b03)
Java HotSpot(TM) Client VM (build 1.5.0_07-b03, mixed mode, sharing)
6. Finally, try running it ... IN THE CURRENT DIRECTORY:
Quote:
java hello
hello java!
Please post back your results - a lot of people are interested in the outcome !
Ive tried the above suggestions and I still get an unsupported class version error. Java is working and installed from the sun website and java and, the compiler should be the same version becuase im pretty sure jre gets installed along with the JDK.
Is there really any reason for you to keep a secret from us outputs like "java -version", "javac" and "which java"? Because if you have posted that from the beginning we should know for sure if java is correctly installed as it should and that both the java sdk and re are the same. Some distributions ship with a replacement for java sdk/re called gcj and that is a very common problem in here lately. Even if you've installed java correctly but did not configured your path, you might still be running the gcj instead of Sun's Java RE (which I am quite positive you have, since you did not include java on your path according to this post number 14 here.
Just post the output of the above commands so we can make sure if that is your actual problem or if your problem lies somewhere else...
Last edited by Mega Man X; 12-13-2006 at 12:09 AM.
indienick:
I tried that and I get the same error messages as before.
I just tried something different. I logged in as root and tried it, but I had to put ./ in front of javac and java, the long list of errors went away but I still get:
"Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldApp/java"
java -jar HelloWorldApp.jar assuming that you defined the main-class in te jar manifest.
java HelloWorldApp if the HellWorld app is not in a package!?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.