hi

i have red hat 9 on the system. i downloaded java sdk for linux path from sun and installed it. but still it says javac command not found even though i renamed the path using the locate javac command.

Dani AI

Generated

The problem reported by is the usual PATH/environment issue: the shell cannot find the compiler because the environment was changed incorrectly or not applied. is right that locate only reports where a file lives. is also correct that PATH entries must be directories (not the javac executable), and ’s question about install location/root is relevant — an install in a home directory needs the correct $HOME path in the environment.

A concise, correct approach is to point the environment at the JDK bin directory and export it (no spaces around =). An example that avoids editing system files directly:

export JAVA_HOME="$HOME/jdk1.4.2_06"
export PATH="$JAVA_HOME/bin:$PATH"

After changing a profile file, the environment must be reloaded (login/logout or source the profile) for interactive shells started afterwards. Verification commands that report what the current shell will run are useful:

command -v javac
type -a javac
ls -l "$JAVA_HOME/bin/javac"

If javac still does not appear, check that the file exists at the expected location and has execute permission. For GUI terminals or non-login shells, .bashrc may be read instead of .bash_profile; for a system-wide installation, place the exports in /etc/profile.d/. If the JDK was installed by root into a system directory, prefer a system-wide PATH; if installed in a user home, use $HOME or the explicit home path.

Summary of the thread’s fixes: do not use locate to change the environment, do not add the javac filename to PATH (add the bin directory), remove spaces around = in assignments, export the variable, and ensure the updated file is sourced or a re-login is performed. These steps resolve the “command not found” symptom in the vast majority of similar Red Hat 9 setups.

Recommended Answers

All 6 Replies

The locate command doesn't rewrite anything - it just tells you where xxx is located.

Try doing updatedb, followed by locate xxx to see where it is (like, /usr/local/bin or /usr/sbin or whatever the path is) and maybe at that location to yoru $PATH if it isn't already there.

hi

i have red hat 9 on the system. i downloaded java sdk for linux path from sun and installed it. but still it says javac command not found even though i renamed the path using the locate javac command.

did you add a PATH= pointing to the location of your java install? did you install as root or as a user? did you install to the standard location?

did you add a PATH= pointing to the location of your java install? did you install as root or as a user? did you install to the standard location?

yes i added the javac path using the "locate javac" command i installed it in my home folder i dont know if it is user or rool

I mean, do you have a section in your PATH= that reads '/home/xxxxx/path/to/javac/'?

i did this in .bash_profile

PATH = $PATH:/usr/java/j2ske1.4.2-06/bin/javac
export PATH

i found the path by typing locate javac in terminal.

but still i get this error:

bash: javac : command not found

i did this in .bash_profile

PATH = $PATH:/usr/java/j2ske1.4.2-06/bin/javac
export PATH

Just at first glance (although it may not be the fix): your PATH statement should only point to the directories in which executables reside, not to the executables themselves; try this instead:

PATH = $PATH:/usr/java/j2ske1.4.2-06/bin:
export PATH

You may also have to export other environment variables besides PATH, such as CLASSPATH- more info and suggestions can be found in the results of this G4L search:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.