1
Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "/usr/lib/jvm/java-6-openjdk-i386/jre"

Erm.. But it is pointing to a JDK, open-JDK here. Am I missing out on something here?

Hick
  • 35,524
  • 46
  • 151
  • 243
  • No, that's the `jre` (Jave Runtime Environment), not the JDK. Related: http://stackoverflow.com/questions/5736641/ant-unable-to-find-javac-java-home-wont-set-on-ubuntu/5736774#5736774 ... did you actually install the JDK? (Don't ask me why they package it like that) – Brian Roach Dec 24 '12 at 15:57
  • I did install the jdk. But it still doesn't work. – Hick Dec 24 '12 at 17:00
  • Then you just have to set you `JAVA_HOME` correctly, not pointed at the JRE. The other answers to that question explain how. – Brian Roach Dec 24 '12 at 17:03
  • I did that in the bash file but still the same error continues. – Hick Dec 24 '12 at 17:46

3 Answers3

1

Ignore all solutions which suggest adding/setting a JAVA_HOME directory, they are wrong. If you have one set in your .profile etc, remove it.

Ubuntu (and a number of other distros, esp. debian based ones) use an 'alternatives' mechanism to provide a higher level of abstraction to handle things like multiple versions of the same software or multiple sotware packages which provide the same functionality, such as web browsers.

Ubuntu does not require a JAVA_HOME setting, provided you let the OS and it's packaging system manage your environment. If your manually installing things, your then on your own and need to work it out.

I suspect that originally, you only had the JRE installed, you then attempted to fix your problem by adding a JAVA_HOME setting and then later installed the required JDK. If this is the case, remove your JAVA_HOME setting and then use the update-alternatives command to make sure the correct java environment has been setup (see the man page for update-alternatives for details - its very easy).

The advice on using lein is IMO spot on and I would also recommend using the script rather than the packaged version. I would also recommend going witht he 2.0 preview version. It is quite stable and a better place to start than the older 1.x versions.

Tim X
  • 4,158
  • 1
  • 20
  • 26
0

Remove the jre part in the path. That should do the trick.

It would become

"/usr/lib/jvm/java-6-openjdk-i386"

Also as Brian suggested try

sudo apt-get install openjdk-7-jdk
Sri Harsha Chilakapati
  • 11,744
  • 6
  • 50
  • 91
  • 1
    With the "close as duplicate" function on SO you shouldn't copy/paste the solution from the one people mark as a duplicate ... – Brian Roach Dec 24 '12 at 16:22
0

You could just install leiningen (which is packaged with Ubuntu). This will give you a nice project tool for working with Clojure. It bootstraps and pulls clojure in for you on a per package basis, which will also mean that you have more than one version.

Phil Lord
  • 2,917
  • 1
  • 20
  • 31
  • 2
    Don't install leiningen with the ubuntu package manager, just run the script from git. The apt version is still at 1.7.1. (never install packages without first checking if they are reasonably up-to-date). – Cubic Dec 24 '12 at 23:43