Using Notepad++ to Compile and Run Java Programs

25 07 2008

I had been using Notepad- The one that comes with Windows for a long time for writing Java programs and then running it through command line, though i had Notepad++ installed on my system. But then it just flashed to me that “Why can’t i try Notepad++ for compiling and interpreting the Java programs“. I searched in the FAQs under “Running External Tools” and found useful information which has helped me to compile and run the Java programs right from the “Notepad++” application itself. Here’s how it can be done:

Running External Tools in Notepad++:
External tools can be executed by passing the current edited document as argument. For doing this the “environment variable” is used

The usage of Environment Variable:
$(ENVIRONMENT_VARIABLE)

Ex: Lets say we are editing “NotHelloWorld.java”

The 5 environment Variable that can be used are:
FULL_CURRENT_PATH: C:\Documents and Settings\Administrator\My Documents\JavaP\NotHelloWorld.java
CURRENT_DIRECTORY: C:\Documents and Settings\Administrator\My Documents\JavaP\
FILE_NAME: NotHelloWorld.java
NAME_PART:NotHelloWorld
EXT_PART:java

Note: The environment variables must be enclosed with in double quotes.
“$(ENVIRONMENT_VARIABLE)”

For Java Compiler its: javac “$(FILE_NAME)”
For Running the Program i.e interpreting the byte code its: java “$(NAME_PART)”

The screenshots can guide u much better:

Above: Program Snapshot

 

Above: Using the “Run” Menu

 

 

Above: Typing in the “javac” command for Compiling

 

Above: Typing in the “java” command for interpreting the Byte Code

 

Above: The Output Obtained

One can click on “Save” to Save the commands, and the next time the same can be accessed through the “Run” menu.


Actions

Information

Leave a comment