Wednesday, 1 April 2015

How to use Notepad++ AS Java IDE

Generally in schools and colleges IDEs like Netbeans and Eclipse are not provided at initial stage of learning JAVA, because IDEs seems to be complicated for beginners.
Also in IDEs it is easier to identify errors so in exams they asks you to use a text editor and command prompt to compile and run programs.
So to do practice for your exam, ditch your IDE for a while and use this.

  1.  Install JDK and Set Enviroment Variables. (Check if "javac -version" command is working in dos mode)
  2. Download Notepad++ Installer from this page and install it on your PC, if it is not already installed.
  3. Now run Notepad++, and go to the menu option Plugins/Plugin Manager/Show Plugin Manager and install NPPexec Add script by following method
  4. Plugins/NppExec/Execute… (or Press F6)
    1. You’ll see a box that says “Temporary Script”
      Paste in following code:

      javac $(FILE_NAME)
    2. Click “Save…”
    3. Then type in “JAVA Compile” (this is the name of your script)  and click Save
    4. You then get back to the previous screen and have the choice of clicking OK or CANCEL. Click “Cancel” which exits NppExec without running the script (OK would run it)
      Go back to Plugins/NppExec/Execute… (or Press F6) and repeat these steps to enter the following scripts .

      (Note:first select “Temporary Script” to clear the box so that you can paste the new script )

      java  -classpath "$(CURRENT_DIRECTORY)" "$(NAME_PART)"

    5. “JAVA Run” will be the name of this second script. It will run the Java program after it has been compiled.
  5.  Now we add the scripts to the Macros menu
    1. Go to the menu "Plugins/NPPexec/Advanced Options"
    2. select both script from “Associated Script” combo box one by one (It will automatically fill in the “Item Name”) and click the “Add/Modify” button.
    3. Check the box at the top that says “Place to the Macros Submenu”
  6.  Now You are done. Write a code and test it.
    (Tips: Change Language to JAVA from menu Language/J/Java and always save file before executing)

No comments:

Post a Comment