Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Java wont execute without full path!! help!!!!

Status
Not open for further replies.

Oxymoron

Technical User
Dec 17, 2000
168
GB
hi.
Got java for linux, decompressed it, and tried a few test programs.
But executables like javac and java would only run, if I included the entire path to them, then the target file!

e.g.
%>/home/joe/j2sdk1.4.1/bin/javac HelloWorld.java

How can I set javac and the like to be accessible throughout the system, like Windows has the PATH command, which can be changed, does linux have/need anything like that????

any and all comments and suggestions are VERY welcome, as I really want to use linux for java, as opposed to windoze!!

thanks; JoE we are all of us living in the gutter.
But some of us are looking at the stars.
 
As a matter of fact, linux has exactly what you describe. There are a few ways of achieving your goal (as is always the case with non-Windows technology) but changing the PATH shell variable is probably the easiest.

In your home directory (where your shell should open when you log in), if you issue "ls -a", you should see some files that begin with a ".". These are "hidden" files and directories, though the meaning of the term does not translate directly to Windows hidden files.

You did not mention what shell you are using (or which distribution, something very necessary for accurate responses in the future) but you will likely find a file name .bashrc, .tcshrc, .cshrc, or .profile. Make a reasonable allowance for those filenames - I use bash and am positive about .bashrc, but it's been a long time since I've used tcsh, zsh, csh, or any others. Each of these files is a shell script that sets up your personal preferences when the shell is opened.

If you edit the file that corresponds to your shell, you will likely find a line that reads "PATH=$PATH;./" or some other similar line. This sets your personal path to coincide with the system path ($PATH), plus the current directory (./). You want to add the path to your java compiler and byte interpreter to this line. Pay heed to the fact that changes will only take effect when the file is executed again. You can do this by logging out and back in, or by doing a "source .bashrc", or "sh .bashrc", or other means, depending on your system.

I strongly suggest picking up a copy of "Linux in a Nutshell", or "Unix ...", or "Running Linux", all from O'Reilly. There are probably more thorough or modern books available, but I find the index and comprehensiveness of these books to be invaluable. The "Unix in a Nutshell" title covers everything from shell configuration (ie: your question) to a manual for vi and sed.

Hope that helps.
 
easier solution, create a symbolic link to the executables in the /bin directory, or set the path in the conf file of the shell your using (or use the command to add eviroment variables for your shell)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top