• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

javac -version on Ubuntu

 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.
I have JD6 running on Ubuntu 7.10, thanks to:
https://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?
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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! ;-)
 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
John, it seems you have not read my reply in the post you started yourself-
https://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
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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-
https://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!
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic