• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javac -version on Ubuntu

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
I have JD6 running on Ubuntu 7.10, thanks to:
http://www.coderanch.com/t/111095/Linux-UNIX/install-JDK-Ubuntu
But I noted something weird:
Upon trying to run java -version I got:
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Server VM (build 1.6.0_03-b05, mixed mode)
But when trying javac -version I got:
Eclipse Java Compiler v_774_R33x, 3.3.1, Copyright IBM Corp 2000, 2007. All rights reserved.

I want to use javac of JDK 6, not the IBM one.
Any ideas?
 
Diego Freniche
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe this helps...

You need to know which executable is fired when you type "javac -version". The "which" command comes to rescue:

So now we know that /usr/bin/javac is the one that "answers" our keystrokes. Is it a real program or a symlink?

What! Is a symlink! Lets ls again:

So probably the /etc/alternatives/javac link will point to the not desired javac. Change it (as root) using:


Maybe you installed Eclipse using synaptic (as an Ubuntu Package)? I'd rather prefer to unpack the tgz off the Eclipse web in /opt. This way I control Ubuntu. And soon the rest of the world. BWUAHAHAHAHAHAHAH! ;-)
 
Rohan Dhruva
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John, it seems you have not read my reply in the post you started yourself-
http://www.coderanch.com/t/111095/Linux-UNIX/install-JDK-Ubuntu


To set ALL the java related symlink automatically to the Sun version of Java (e.g. apt, servtool, jar, javap etc.) do this:

sudo update-java-alternatives --set java-6-sun


Diego, what you're doing is wrong. You should never modify /etc/alternatives links yourself, use the update-alternatives program for that. Read it's man page for more info
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rohan Dhruva:
John, it seems you have not read my reply in the post you started yourself-
http://www.coderanch.com/t/111095/Linux-UNIX/install-JDK-Ubuntu

Well, actually I followed my previous thread literally and all JDK tools are working as expected except for javac which I figured it launches
/bin/ecj
What I did?
I created a symlink to my JDK/bin/javac and moved it to /etc/alternatives
I'm not sure if this is right or wrong but it works!
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15205
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by John Todd:
What I did?
I created a symlink to my JDK/bin/javac and moved it to /etc/alternatives
I'm not sure if this is right or wrong but it works!

As Rohan says, you're not supposed to mess with the links in /etc/alternatives manually, instead you should use update-alternatives to manage this for you. Messing with the links manually might confuse update-alternatives if you'll need to use it in the future.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic