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

前端 未结 9 2102
再見小時候
再見小時候 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:19

    You don't need to do any complex command-line stuff or edit any system code. You simply have to open Computer, showing all of your disks and open properties. From there, go to Advanced System Settings and click Environment Variables. Scroll down in the lower list box and edit Path. Do not erase anything already there. Put a ; after it and then type in your path. To test, open command prompt and do "javac", it should list around 20 programs. You would be finished at that point.

    By the way, the command to compile is javac -g not just javac.

    Happy coding!

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

    That would be:

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

    You can also append ;C:\Program Files\Java\jdk1.6.0_18\bin to the PATH in the user environment dialog. That would allow you to use javac and other java tools directly form any cmd shell without setting the path first. The user environment dialog used to be somewhere in the system properties in XP, I have no idea where it is in Windows 7.

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

    Follow the steps given here

    http://www.javaandme.com/

    after setting variable, just navigate to your java file directory in your cmd and type javac "xyx.java"

    or if you don't navigate to the directory, then simply specify the full path of java file

    javac "/xyz.java"

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