Sabtu, 04 Februari 2012

bash: javac: command not found

judul diatas output di saat saya mencoba kompilasi program java
sebenarnya saya bukan, seorang calon programer atau programer
saya hanya seorang penikmat linux

googling, dapat juga solusinya,
pertama, upgrade versi java , boleh baca di http://deedeeitsme.wordpress.com/2011/08/28/install-sun-jdk-7-di-linux-debian-squeeze
kira2 seperti ini ..

sebelumnya  eskterak dulu  file  " jdk-7-linux-i586.tar.gz"  ke    /usr/lib/jvm/
$ sudo tar -zxvf jdk-7-linux-i586.tar.g -C  /usr/lib/jvm/

lalu :
root@debian:/home/ariyasa# update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/gij-4.4 1044 auto mode
1 /usr/bin/gij-4.4 1044 manual mode
2 /usr/lib/jvm/jdk1.7.0/jre/bin/java 2 manual mode

Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/jdk1.7.0/jre/bin/java to provide /usr/bin/java (java) in manual mode.

lanjut  perintah,

root@debian:/home/ariyasa# update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0/jre/bin/java  2

cek versi java,
root@debian:/home/ariyasa# java -version
java version "1.7.0"

Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode)

kedua,  setting path java, edit file .bashrc, boleh baca di http://ebams.wordpress.com/2010/10/24/setting-path-java-home-dii-linux/

pada baris akhir, tambahkan script ini,

JAVA_HOME=/usr/lib/jvm/jdk1.7.0
export PATH=$PATH:$JAVA_HOME/bin

simpan kemudian logout terlebih dahulu agar file .bashrc dieksekusi. buka terminal dan ketik
$ echo $JAVA_HOME
/usr/lib/jvm/jdk1.7.0

ketiga, bikin program java sederhana boleh baca di http://www.vavai.com/blog/index.php?/archives/590-Program-Java-Pertama-Hello-Java-!.html

public class Halo {public static void main(String[] args){System.out.println("Hello Java");}}


ariyasa@debian:~$javac Halo.java

ariyasa@debian:~$ java Halo
Hello Java
ariyasa@debian:~$

running @ debian squeeze
terima- kasih ,
note : bila sobat ada yg mau coba cara di atas, jgn di copas commandnya, ketik aja manual di terminal..
selesai ..

Tidak ada komentar:

Posting Komentar