I installed java on my machine and I wanted to compile this group of source code. But when I opened up the command prompt and typed in javac, the command prompt said it was an unknown parameter. The same thing happened when I wanted to build something with ant (I had the build.xml if you are wondering) and the same thing happened. How can I set the javac and ant command to be used in any directory?
3 Answers
First of all you have to be sure you installed JDK and not only JRE
Secondly it depends on your operating system:
- windows: you have to reach environment variables by using My Computer (manage->advanced->something here)
- linux/osx: you have to export variables with export command or by using a .profile file in user directory
Then you need to set two things:
- adding /jdk_1.6.../bin/ to your PATH variable
- setting JAVA_HOME to your root of java installation ( /java_1.6..../ ) (maybe this is not required by java itself but many frameworks use it)
One note: on OSX, and maybe Linux too you have to split paths in PATH variable with double colon ':' instead that semicolon ';'