aspose file tools*
The moose likes Linux / UNIX and the fly likes javac -version on Ubuntu Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "javac -version on Ubuntu" Watch "javac -version on Ubuntu" New topic
Author

javac -version on Ubuntu

Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

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

Joined: Dec 28, 2007
Posts: 8
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! ;-)


SCBCD 1.3, SCWCD 1.5, SCJP 1.5 & 1.6
Rohan Dhruva
Ranch Hand

Joined: May 08, 2007
Posts: 183
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


Rohan B. Dhruva
SCJP 1.5
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

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

Joined: Aug 16, 2005
Posts: 13869
    
  10

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javac -version on Ubuntu
 
Similar Threads
UnsatisfiedLinkError
Regex start() + group() question
Getting Version Numbers
Java version
Unsupported major.minor version 50.0