Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

javac

  Asked By: Fern    Date: Oct 01    Category: Java    Views: 642
  

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

 
Answer #1    Answered By: Sherrie Thomas     Answered On: Oct 01

Brush up path - classpath stuff... .........

 
Answer #2    Answered By: Anselma Schmidt     Answered On: Oct 01

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:

var name: PATH

var value: .;%PATH%;"C:\Program Files\Java\jdk1.5.0\bin"

 
Answer #3    Answered By: Dang Tran     Answered On: Oct 01

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

 
Didn't find what you were looking for? Find more on javac Or get search suggestion and latest updates.




Tagged: