-   Linux - Newbie (
-   -   How to use jdk for java programming (

bajaj15 03-12-2010 10:49 AM

How to use jdk for java programming
Hi all
I would like to run java program on fedora10,but I am facing some problems .when I use which java command it show usr/bin/java directory.I was trying to set the java_home path in bash_profile,but there is no affect.Tell me how can I solve my problem?
Thanks in Advance

arashi256 03-12-2010 11:00 AM

Are you sure /usr/bin/java is a directory and not an executable?

You'd be better off downloading the official Sun JDK for Linux from their website - it's faster than the open JDK.

Anyway...either is fine.

You can add the JAVA_HOME environment variable to /etc/profile (system-wide) - but I doubt you'll need it if you're using the JDK supplied with Fedora 10. Why do you feel you need this environment variable set up?

I use the Sun JDK myself, so my /etc/profile reads as: -

export PATH=/usr/local/java/bin:$PATH
export JAVA_HOME=/usr/local/java

Compile with: - javac -cp .[:<any .jar libraries you want to include] *.java
Run with: - java -cp .[:<any .jar libraries you want to include] <Java program name>

paulsm4 03-12-2010 11:07 AM

Hi -

Actually, I generally recommend that you:

1. Uninstall Gnu java
2. Download and install the Sun JDK (which includes compiler, runtime and the NetBeans IDE).

At a minimum, I would *definitely* recommend configuring Java with "alternatives":


[mirandam@charon ~]$ sudo /usr/sbin/alternatives --install /usr/bin/java java /opt/jre1.6/bin/java 2
[mirandam@charon ~]$ echo 2 | sudo /usr/sbin/alternatives --config java

[mirandam@charon ~]$ java -version
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)
<= This example shows how to configure "Sun JDK" as the default
'Hope that helps .. PSM

I completely agree with arashi256: the Sun JDK is definitely the right choice. For many different reasons...

All times are GMT -5. The time now is 11:03 PM.