I have an ubuntu 11.10 with eclipse installed, now I am supposed to need JVM, Java compiler and something called API. I am starting to learn Java, because it is easy to make it work on windows after. So what do I install?


I am supposed to need JVM, Java compiler and something called API

The Java Virtual Machine (JVM) is what runs the Java applications (compiled into bytecode). The Java API is the set of existing features that are implemented the runtime libraries: everything documented here. Both the JVM and the runtime libraries form the Java Runtime Environment (JRE). Its main command is java.

The Java compiler, used via the javac commandin the Java Development Kit (JDK), is what turns source code into bytecode, which can be run with the JRE.

The OpenJDK JRE is available in the openjdk-6-jre package and the OpenJDK in the openjdk-6-jdk package (which depends on openjdk-6-jre anyway).

Eclipse needs the JRE to run, but provides its own compiler (Eclipse JDT). Strictly speaking, you don't need the JDK to develop with Eclipse, you could compile everything within Eclipse and run your applications through the JRE.

This being said, if you're a beginner, it's certainly worth trying a few toy applications with javac, if only to understand how the compilation process, package/directory structures and classpath work. IDEs like Eclipse can make a lot of this conveniently automated or invisible (which can be very useful), but knowing the basics helps when you run into problems. Unless you're short of disk space, it makes sense to install both the JRE and the JDK, even if you're using Eclipse.

|improve this answer|||||

Depending on which version of java jre you use, you need to install a jdk, for example the package openjdk-6-jdk.

Once you've done that, you should be able to run a javac command to compile .java files.

For example A.java:

class A {
    public static void main(String[] a){

then compile to A.class

$ javac A.java

And run:

$ java A

This should output

> hello

Then the easiest thing to do is just to install Eclipse, and get started.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.