Click to See Complete Forum and Search --> : which file to add the java path


jtruong
01-18-2003, 01:30 PM
I've added to the root's .bashrc:

PATH='$PATH:/usr/java/j2re1.4.1_01/bin'
export PATH

but then i get miscellaneous commands not found! I have to type the whole path for everything as though my PATH got all screwed up.

Did i edit the right file? Did i add the path correctly?

Thanks,
jtruong

ashoksagar
01-18-2003, 02:19 PM
export PATH=$PATH:/usr/java/j2re1.4.1_01/bin
also

export JAVA_HOME="/usr/java/j2re1.4.1_01"

bwkaz
01-18-2003, 02:40 PM
Yeah, don't use single quotes in the path. Use either double quotes or none at all.

Single quotes stop the $ character from starting an expansion, so $PATH doesn't turn into the real current path. Double quotes don't do that.

jetblackz
01-18-2003, 03:19 PM
This is a programming forum so I assum you're programming Java. In that case, you should've gotton SDK.

BTW, do

whereis java

and you should remove that old bin temporarily

mv /usr/bin/java /usr/bin/java.bak

Now run java again.

jtruong
01-18-2003, 03:52 PM
I've also tried the sdk but had the same problem.

jetblackz
01-19-2003, 08:14 PM
Tell me what you see

java -version

and what you downloaded & installed

StarmanDeluxe
01-20-2003, 12:12 AM
Hmmm I am trying to figure this out too. I added the following to my profile after "unset i"

export PATH=$PATH:/usr/java/j2re1.4.1_01/bin
export JAVA_HOME="/usr/java/j2re1.4.1_01"
export CLASSPATH=./:~/java/classes

I also tried "export CLASSPATH=./:~/java/j2re1.4.1_01/clases" as the last line

Neither one helped, Bash keeps telling me the command is unrecognized

jetblackz
01-20-2003, 02:13 AM
re = runtime
sdk = dev. kit

CLASSPATH is an old issue. 1.2 and older needs this.

StarmanDeluxe
01-20-2003, 03:20 AM
I noticed this afterwards and changed it and after Jetblack's post I took out CLASSPATH

So it now says

export JAVA_HOME=/usr/java/j2sdk1.4.1_01
export PATH=$JAVA_HOME/bin:$PATH

and I did source /etc/profile but I still get "bash: java: command not found"

bwkaz
01-20-2003, 10:20 AM
Do a find /usr/java -name java to find out where it is. Report what you get back.

StarmanDeluxe
01-20-2003, 11:44 AM
/usr/java
/usr/java/j2sdk1.4.0_01/bin/java
/usr/java/j2sdk1.4.0_01/jre/bin/java

That's what I got back

bwkaz
01-20-2003, 02:06 PM
Hmm. What about /usr/java/j2sdk1.4.0_01/bin/java -version?

If that works, echo $PATH, take out any duplicated directories, and export PATH=<the non-duplicates>:/usr/java/j2sdk1.4.0_01/bin and try java -version again.

Also, rather than sourcing /etc/profile, you might have to log out. I don't see why that would be, but maybe.

StarmanDeluxe
01-21-2003, 08:43 PM
OHHH jeez, I see what's going on now. The $PATH variable tells Bash where to look for commands that you execute, right? So when you export the PATH that includes the directory that your Java binaries are in it automatically looks THERE then everywhere else, right?

jtruong
01-21-2003, 08:51 PM
I think that's what happening.

Also, there is no path definition in my original .bashrc file, but there is one in the .cshrc file. The definition is a list of directories separated with a ':' char

Should i had a column and the java path there in .cshrc? What is the difference between the .cshrc and the .bashrc file?

jtruong

bwkaz
01-21-2003, 10:52 PM
bash looks in every directory of the PATH for a file that you're trying to execute, yes. It searches these directories in the order that they're listed in PATH. If you put the Java one at the end, then it will be searched last, and if your distro puts an old version of Java in /usr/bin (Mandrake 9, for example, installs some Java version 1.2 or so), it will get executed first. But putting the Java directory at the end still seems like a decent idea to me; I just don't know why. In any case, just make sure you don't have any "java" executables in any other directory in your PATH.

jtruong -- If you use bash, it reads your ~/.bashrc file (well, unless it's being run as a login shell, which happens when you first log in -- then it reads ~/.profile or ~/.bash_profile, whichever one exists). If you're using tcsh or csh (which I believe some distros still come with, but AFAIK it's not the default on any of them...) then it uses your ~/.cshrc file.

Do a grep <your user name> /etc/passwd | cut -d : -f 7 to find out the shell you're using. If it isn't /bin/bash, then you aren't using bash, and none of these PATH changes will do anything. ;)

jtruong
01-24-2003, 07:02 PM
Alright, thanks for your help y'all. I finally got it to recognize the java command. I didn't use any quotes and had to re-log in.

Is there a way to effect the changes made to .bashrc immediately?

jtruong

bwkaz
01-24-2003, 11:34 PM
You might be able to source it -- source ~/.bashrc -- but I think you tried that, right? Actually, it looks like you didn't... hmm.