Saturday, May 22, 2010

Java : Adding 'Compile Program' Option to Context Menu for Java Files

Java programmers & students always find it a tedious process to open command prompt,set path & then compile the program.Here's how to get a compile program option in Context Menu so that we can compile from right click & know the errors in the program.
* Start Notepad & type the following (Note:Replace "c:\program files\java\jdk1.6.0\bin" with your path of JDK).
   @echo off
 path=%PATH%;C:\Program files\Java\jdk1.6.0\bin
 javac "%1"

* Save this file as "compile.bat" & copy this file in c:\windows.
* Open registry editor : Press Winkey + R(Run) & type "regedit.exe".
* Goto "HKEY_CLASSES_ROOT\java_auto_file\shell"
* Right Click on "shell" key & choose New - Key.

* Type Key name "compile".
* In right side pane double click on Default & type "Compile Program" & click OK. 

* Now right click on "compile" key  & click New - Key.

* Type key name as : "command" (without quotes).
* Click On command & in right side pane double click on Default & type : C:\Windows\compile.bat "%1"

* U get the Compile Program option for java files.

* Restart UR Pc
* Have fun..........

Shortcut to Do this :
 For some reason if you are unable to do the above process.Perform steps 1 & 2 & then download this zip  file & double click on reg file in it to add keys to registry for u.

No comments:

Post a Comment