开发者

Java compiler in Ubuntu

I've set up Eclipse in Ubuntu 10.04. I currently have the OpenJDK JRE installed but don't have the JDK needed to compile.

Howe开发者_StackOverflow中文版ver, the code written Eclipse still compiles. Is this a standard compiler included in Eclipse? I've searched through the package manager and don't seem to have any of the JDKs installed...

Note: running 'javac' in the terminal doesn't work.


If you download Eclipse from eclipse.org, it will bring everything it needs to work with it.

Eclipse is designed to be a standalone package which only minimally uses the components of the system on which it runs. This helps to provide the same experience everywhere.

On the down side, it makes Eclipse larger and more RAM-hungry, and also makes keeping Eclipse up-to-date a separate chore from keeping the rest of your system current.

You can see what Eclipse is using by going into your project build settings. It may be using its built-in compiler, which lets it easily highlight errors, rapidly do incremental builds, and such.


For what it's worth, the Java compiler included in Eclipse is a derivative of IBM's jikes compiler. It's not really so important what brand it is; what's important is that it is an incremental compiler; it sort of keeps your whole program inside itself and if you change a class (maybe even just a method) it will re-compile just the bit of code you've changed.

If you look at NetBeans, when you save a changed file it will call up an ant task to re-compile (via the JDK) at least the class you changed, maybe more. When your classes start to get bigger, you'll find (or at least I did) that this takes up a lot of time; I'm very happy with Eclipse (and IBM) for doing things the way they do. Without the external compilation step, code changes take place a lot more quickly.

Yes, the compiler has some differences compared to the "standard" compilers by Sun Oracle and OpenJDK. But I've never experienced a problem as a result. Still, for production use I'd recommend formally compiling using ant or maven and the JDK. Just to be on the safe side.


Eclipse, like unfortunately most substantial applications that require a JRE/JDK to run include it in the distribution.

For a good time on Lucid Lynx:

$ locate javac


You'll need to another source to the repository. Run the following commands.

sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo apt-get update
sudo apt-get install sun-java6-jdk


There's a package for eclipse called eclipse and the java compiler (javac) is in sun-java6-jdk

Install it with sudo apt-get install sun-java6-jdk or sudo apt-get install eclipse


Eclipse does come with its own compiler, but I wouldn't recommend using it for distribution of source code. I'm not intimately familiar with it, but I've been told that it doesn't perform optimizations as well as other compilers and there are some known bugs in it. I can't dig up anything that supports this, but I do like the idea of building using the same JDK/compiler and running on the same JVM that your users are.

I would suggest obtaining the Sun JDK for Linux. You should be able to get it from the Synaptic Package Manager if you open the universe repositories.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜