PDA

View Full Version : [SOLVED] javac



uburudu
February 3rd, 2012, 12:04 PM
Hello !

I have problem with my java instalation, i can compile java code with Eclipse IDE but i cannot compile on terminal ( with javac ) ... i couldn't find any solution on older posts and i'm a bit confused...
i think i have messed up my system :S

related commands & output:


username$ lsb_release -r
Release: 11.10ubuntu 11.10 (x64)
.


username$ java -version
java version "1.6.0_23"
OpenJDK Runtime Environment (IcedTea6 1.11pre) (6b23~pre11-0ubuntu1.11.10.1)
OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)
username$ .


username$ 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>
username$ .


username$ sudo apt-get install openjdk-6-jdk
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.
username$

.


trying to compile with Geany i get the msg:

javac "HelloWorld.java" (in directory: /home/username)
Compilation failed.
/bin/sh: javac: not found



.



username$ cat HelloWorld.java
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
username$

doobrie
February 3rd, 2012, 12:10 PM
It looks like you have javac already installed. If you execute

$ which javac

Does it show you the installation path?

I've found java 7 to be better. Have you tried using that version?

uburudu
February 3rd, 2012, 12:19 PM
username$ which javac
username$
it doesn't give me any output

but with " $ locate javac " i can see a path " /usr/lib/jvm/java-6-openjdk/bin/javac "

-

i tried
sudo apt-get openjdk-7-jdk
yesterday with the same results

uburudu
February 3rd, 2012, 01:13 PM
not sure if there is a better solution

but i made manually a javac link at "/usr/bin/" dir and it fixed my problem


username~$ sudo ln -s /usr/lib/jvm/java-6-openjdk/bin/javac /usr/bin/javac


thnx for the reply @doobrie, and my friend MITSARAS !

KOSEOS!
bb

doobrie
February 3rd, 2012, 01:21 PM
For some reason you have the compiler installed, but it wasn't in your path (hence making the link worked).

Making the link is a good solution.