javac command prompt parameters
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 a开发者_JAVA百科nt (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?
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 ';'
Add the directory the executable is in to the PATH
environment variable.
Guessing that you are using Windows. Right click My Computer
and click Manage
. Then, in the Advanced
tab, select Environment Variables
. In the new window, under System variables
, find Path
and append the full path to the binaries (javac
and ant
) at the end, separated by semicolons.
精彩评论