How can I set the PATH variable for javac so I can manually compile my .java works?

前端 未结 9 2101
再見小時候
再見小時候 2020-12-01 23:44

Here\'s the address on my drive:

C:\\Program Files\\Java\\jdk1.6.0_18\\bin

How would I go about setting the path variable so I c

相关标签:
9条回答
  • 2020-12-02 00:06

    Typing the SET PATH command into the command shell every time you fire it up could get old for you pretty fast. Three alternatives:

    1. Run javac from a batch (.CMD) file. Then you can just put the SET PATH into that file before your javac execution. Or you could do without the SET PATH if you simply code the explicit path to javac.exe
    2. Set your enhanced, improved PATH in the "environment variables" configuration of your system.
    3. In the long run you'll want to automate your Java compiling with Ant. But that will require yet another extension to PATH first, which brings us back to (1) and (2).
    0 讨论(0)
  • 2020-12-02 00:07

    Step 1: Set the PATH variable JAVA_HOME to the path of the JDK present on the system. Step 2: in the Path variable add the path of the C:\Program Files\Java\jdk(version)\bin

    This should solve the problem. Happy coding!!

    0 讨论(0)
  • 2020-12-02 00:08

    Trying this out on Windows 10, none of the command-line instructions worked.

    Right clicking on "Computer" then open Properties etc. as the post by Galen Nare above already explains, leads you to a window where you need to click on "new" and then paste the path (as said: without deleting anything else). Afterwards you can check by typing java -version in the command-line window, which should display your current java version, if everything worked out right.

    0 讨论(0)
  • 2020-12-02 00:12
    1. Type cmd in program start
    2. Copy and Paste following on dos prompt

    set PATH="%PATH%;C:\Program Files\Java\jdk1.6.0_18\bin"

    0 讨论(0)
  • 2020-12-02 00:13

    First thing I wann ans to this imp question: "Why we require PATH To be set?"

    Answer : You need to set PATH to compile Java source code, create JAVA CLASS FILES and allow Operating System to load classes at runtime.

    Now you will understand why after setting "javac" you can manually compile by just saying "Class_name.java"

    Modify the PATH of Windows Environmental Variable by appending the location till bin directory where all exe file(for eg. java,javac) are present.

    Example : ;C:\Program Files\Java\jre7\bin.

    0 讨论(0)
  • 2020-12-02 00:16

    only this will work:

    path=%set path%;C:\Program Files\Java\jdk1.7.0_04\bin

    0 讨论(0)
提交回复
热议问题