LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   set up path,classpath in linux(slaware9) for java (https://www.linuxquestions.org/questions/linux-software-2/set-up-path-classpath-in-linux-slaware9-for-java-100729/)

Manjula.S 10-06-2003 03:06 AM

set up path,classpath in linux(slaware9) for java
 
i downloaded j2sdk in my linux.dont know how to set up path and classpath in linux.i am using slackware9.please help

Tinkster 10-06-2003 03:09 AM

Use the search, Luke.

Cheers,
Tink

hw-tph 10-06-2003 08:20 AM

I'll just paste my answer to a similar question posted on knoppix.net:

Quote:

Sun does not use an open license for Java so it is not included with the official Debian archives, so you can't apt-get install with a stock /etc/sources.list file.

However, the Blackdown project (blackdown.org) provides Java packages for Debian (and many others). These are not very up to date (usually) so I just download the Java SDK (not the JRE!) from Sun and install it.

Here's how you do it:

1. Download the "Linux self-extracting file" package from http://java.sun.com/j2se/1.4.2/download.html

2. Create a directory for Java related stuff under /usr/local:
$ cd /usr/local
$ su (enter password for root, note that the prompt changes when you're root)
# mkdir java
# cd java

3. Then you need to run the file. With this file you can do it like this:
# sh j2sdk-1_4_2_01-linux-i586.bin
....or like this:
# chmod +x j2sdk-1_4_2_01-linux-i586.bin (this makes the file executable)
# /home/hw/downloads/j2sdk-1_4_2_01-linux-i586.bin (execute it - run this from the /usr/local/java directory)

4. Now it's installed. Still, the java and javac commands won't work from the command line because the /bin subdirectory from the SDK isn't in the path. We need to add them somehow. There are many different ways of doing this but this is how I usually do it:
Edit /etc/profile (as root) with your favourite text editor. There should be a line that specifies directories that contain executables and should be added to the PATH environment variable. Something like this:
PATH="/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games"
The directories are separated by colons(. Add a colon at the end of the line (but before the closing quote) and add the Java bin directory. If you followed my outline above it should be /usr/local/java/j2sdk1.4.2/bin/.
Now the line looks like this:
PATH="/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/usr/local/java/j2sdk/bin"
Save the file!

Either log out and log in again or do a "source /etc/profile" to let the changes take effect. Type "javac" at the shell prompt and you should see the exact same thing as you see on Windows!
hw

Tinkster 10-06-2003 09:49 PM

Quote:

Edit /etc/profile (as root) with your favourite text editor. There should be a line that specifies directories that
contain executables and should be added to
the PATH environment variable.
May I suggest a modification?
If you update the system via CD, you're quite likely
to have a new /etc/profile and need to make
the changes again or merge the two files...
Also, making changes to a central file like
profile isn't necessarily a good idea for n00bs.

I'd suggest making a file
/etc/profile.d/java.sh
and make it look like this :)
(modify to match your paths ;})

Code:

#!/bin/sh
# Add JDK specific settings
export JAVA_HOME=/usr/java
export PATH=$PATH:/usr/java/bin:/usr/java/jre/bin

Cheers,
Tink

simplico 10-06-2003 10:02 PM

or you could edit .bash_profile in your home directory (something like /home/*user*/.bash_profile --when you have to type in the file you want to open, type .bash_profile). and add the line :

:/usr/java/j2sdk1.4.2_01/bin

to the end of your PATH line

Manjula.S 10-06-2003 11:38 PM

Thanks a loooot
 
i edited the /etc/profile and set the path .javac is now working.


All times are GMT -5. The time now is 02:56 AM.