javac

if i install j2sdk1.4.0_02 (Sun IDE), my command prompt must know javac command in any address of my machine or only in etc\j2sdk1.4.0_02\bin address?my command prompt only know this command in this address. this is correct?i want to run a jar file with command "javac -jar myjarfile.jar", my file is located in desktop and in this address my command prompt don't know this command.what is the problem?

Share:

3 Answers Found

if you want use java and javac Command for all directory can define PATH and CLASSPATH Var in OS's Environment variables that CLASSPATH for JDK's home directory and PATH for BIN folder of JDK's directory for example:

No! command prompt (cmd) does not know what âjavacâ is until you create a variable named âpathâ. Following, I tell you how you can set up this variable.If you set up the âPATHâ variable, you can access to âjavacâ and other files in everywhere in your computer regardless of where you are.

In order to set up this variable, under windows XP, you should do these:1. Start/Control Panel/System/Advanced tab/2. Click on âEnvironment Variableâ3. In âEnvironment variableâ window, there are two locations: âUser variablesâ and âSystem Variablesâ. In âSystem Variablesâ find a variable named âPATHâ (If you can not find this variable, click on ânewâ, otherwise click on âeditâ)4. If you click on ânewâ enter âVariable nameâ as âPathâ and enter âVariable valueâ as you JDK or SDL installation directory. For example, if you install JDK in âD:\Java\jdk1.5.0_06\â you should type âD:\Java\jdk1.5.0_06\binâ (because javac is in bin directory)5. If you click on âeditâ, after all the âVariable valueâ content, type â;â and then âD:\Java\jdk1.5.0_06\binâ (This is where I install JDK). For example like this: âsome other things; D:\Java\jdk1.5.0_06\binâ.6. Click on all âokâs.Now, open a command window (start/run/cmd) in order to check whether you do the above lines correctly. Enter for example âjava âversionâ or âjavac helpâ. If you see an error message, you are doing something wrong, otherwise everything is ok.

Now, you can navigate to your project folder. For example if you have a âtest.javaâ file in your desktop, navigate to your desktop in cmd and then enter javac test.java, and then java test