Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

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.

share|improve this answer
add comment

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){
        System.out.println("hello");
    }
}

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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