I spent sometime today trying to compile and then run Java using Notepad++ so I figured that I would write a guide explaining how to do it.

For those of you who don’t know Notepad++ is one of my favorite text editors.

Step 1) Download and install the Java JDK from http://www.oracle.com/technetwork/java/javase/downloads/index.html

Step 2) Setup your path variables

Step 2.1) Go to your control panel and search for path

Step 2.2) Click on edit the system environment variables

Step 2.3) Click on environment variables

Step 2.4) Find your path setting

Step 2.5) Click on your path variable and then click on the edit button

Step 2.6) At the end of your path variable add the following: “;C:\Program Files\Java\jdk%JDK-VERSION%\bin” where %JDK-VERSION% is your JDK version number. (You can also find this by browsing to c:/program files/java and looking at the folders there)

Step 3) Log off your computer and then log back in. (You can also reboot if you want, but that is unnecessary)

Step 4) Somewhere on your computer make a new text file and add the following to it:

cd /d “%1″
javac %2 -Xlint:all
if errorlevel 1 goto finish
java %3
:finish
pause

Step 5) Rename this file to CompileJava.bat (if the file name does not end it .txt before you rename you will need to do this first)

Step 6) Copy this file to C:/Program Files/Notepad++

Step 7) Hit the “F5″ key and type the following into the text field $(NPP_DIRECTORY)\CompileJava.bat “$(CURRENT_DIRECTORY)” “$(FILE_NAME)” “$(NAME_PART)”

Step 8 ) Click on save and name the command something like “CompileJava”, you can also set up a key command if you like.

Step 9) You can now access your command from the “Run” menu

Thats it, your now ready to create and run Java code from Notepad++! One important note though, only Java programs with default package will compile and run.

Cried goes to Tech Travel Think for the .bat code.