Javac not installed with openjdk-6-jdk

18,907

Solution 1

Check /etc/alternatives and /usr/bin. One or both will contain links to old Java versions which you had installed. When those links are broken, you can get the error message above.

To update the links after installing a new version of Java, try update-alternatives

Solution 2

TL;DR: install java-1.6.0-openjdk-devel

I had a similar issue on Fedora, but used rpm -q -l to list the contents of the (pre-installed) java-1.6.0-openjdk package, and discovered that it doesn't include javac. It is in fact only a JRE, not a JDK, as implied by the installation instructions on http://openjdk.java.net/install/ . To get javac, I installed java-1.6.0-openjdk-devel . Not exactly what I expected, because the usual packaging conventions would indicate that is the package for doing openjdk development (i.e., working on the JVM), not for developing programs with it.

Basically, openjdk's package naming doesn't follow either standard Java conventions (would require calling it a JRE somewhere), or standard Linux packaging conventions (using -devel indicates it is used for developing the package w/o -devel itself).

Solution 3

As per http://openjdk.java.net/install/, to install the OpenJDK-6 JRE only:

$ sudo apt-get install openjdk-6-jre

To install the full JDK:

$ sudo apt-get install openjdk-6-jdk

Solution 4

First to check if javac is installed try to look for that file: 1. locate javac 2. or find / -name javac

And also you can check at this website with instrucions on how to install java on Ubuntu (i suppose you are on ubuntu):

http://openjdk.java.net/install/

You can also check: http://packages.ubuntu.com/hardy/i386/openjdk-6-jdk/filelist for the files installed by the pacakge, and you can notice that javac should be installed. Maybe you also need to run: Open the terminal and run this command to install OpenJDK 7.0 on Ubuntu Oneiric:

sudo update-alternatives --config java

Share:
18,907
Bas Jansen
Author by

Bas Jansen

Machine Learning Engineer @ Omina Technologies General Disclaimer: I am a horrible programmer (according to myself) and still trying to learn new things on a daily basis so forgive me if I ask something that might seem silly ;)

Updated on June 09, 2022

Comments

  • Bas Jansen
    Bas Jansen almost 2 years

    I have been trying some different java compilers over the weekend and decided to stick with javac this morning. I then proceeded to clean up the mess that was caused by my testing and removed every last trace of java and did a fresh 'apt-get install openjdk-6-jdk' after autoremove and autoclean.

    The following weirdness was then encountered:

    tarskin@5-PARA-11-0120:~$ javac
    The program 'javac' can be found in the following packages:
     * openjdk-6-jdk
     * ecj
     * gcj-4.4-jdk
     * gcj-4.6-jdk
     * gcj-4.5-jdk
     * openjdk-7-jdk
    Try: sudo apt-get install <selected package>
    

    I had allready installed openjdk but i tried it anyhow yielding:

    tarskin@5-PARA-11-0120:~$ sudo apt-get install openjdk-6-jdk
    [sudo] password for tarskin: 
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    openjdk-6-jdk is already the newest version.
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    tarskin@5-PARA-11-0120:~$ 
    

    I know i must be doing something stupid but I have no idea what, if anyone else could give a pointer in the right direction that would be very much appreciated...

    Cheers

    EDIT: Found some other weird aspects about the 'new' instance of my java distro, it doesn't seem to recognise for example 'Pattern' or 'Matcher' that should be coming from the regex import shrugs.

    • Vishy
      Vishy over 12 years
      I suspect it's there but not in your PATH.
    • Bas Jansen
      Bas Jansen over 12 years
      I'll go hide in the corner in shame now.... Shouldn't apt have handled that however? Any idea why it's not recognising the java.util.regex package as well?
    • Bas Jansen
      Bas Jansen over 12 years
      I'm not using any, I normally write my code with Vim and then compile it with javac.
    • Vishy
      Vishy over 12 years
      I used to using vim/javac as well, but was converted to using IntelliJ 7 years ago and I wouldn't go back to doing things the hard way. ;)
  • Bas Jansen
    Bas Jansen over 12 years
    It is installed in /usr/lib/jvm/java-6-openjdk/bin/javac but for some reason the install did not create a symlink in /usr/bin like it should have done, at least i am assuming that is where the link was before i decided to 'clean' my system.
  • Bas Jansen
    Bas Jansen over 12 years
    I ended up manually changing my path to include the install directory of the openjdk which at least means javac is now accessible from everywhere again, just need to get the other bug(s) sorted where it can't import certain packages.
  • Bas Jansen
    Bas Jansen over 12 years
    The FS had indeed not made a new link. Would you happen to have any ideas why my import is failing as well?
  • Aaron Digulla
    Aaron Digulla over 12 years
    @Bas: Open a new question with the Java version, the import statement and the error message plus anything unusual on the classpath (like Jakarta oro).
  • Bas Jansen
    Bas Jansen over 12 years
    I will do that in the morning, unless I have some form of an epiphany because I don't want to 'spam' this board with silly questions.