"Compile Java" and "Run Java Application" options in Notepad ++ ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dmstn
    New Member
    • Feb 2007
    • 16

    #1

    "Compile Java" and "Run Java Application" options in Notepad ++ ?

    Is it possible to add those options in Notepad ++ ?
    Your help would be appreciated very much.
    Thanks in advance.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by dmstn
    Is it possible to add those options in Notepad ++ ?
    Your help would be appreciated very much.
    Thanks in advance.
    Under the run tab, click "Run ..."

    Then in the textbox provided type
    javac NameOfJavaFile. java

    To run it use the java command.
    I hope your console doesn't disappear too quickly as does mine such that everytime when I write scripts in notepad++ I compile them from the windows command prompt .

    Comment

    • dmstn
      New Member
      • Feb 2007
      • 16

      #3
      Ah, I see. Useful.
      But yeah. The DOS window disappeared quickly when I ran the program.
      Thanks anyway.

      Comment

      • alexgt89
        New Member
        • Mar 2008
        • 1

        #4
        I've found the way to compile & run Java applications from Notepad++ with just one hotkey.
        First of all, go to the directory where you have installed Notepad++ and create a new file called CompileJava.bat
        then open it and enter these lines (without line numbers):
        Code:
        @echo off
        path=%path%;"<path to your BIN directory of JDK>"
        @echo on
        javac %1
        java %2
        pause
        Save the file and exit.
        After that, open Notepad++ and press F5. Fill in the box in the small window that appears with (without line number):
        Code:
        $(NPP_DIRECTORY)\CompileJava.bat $(FILE_NAME) $(NAME_PART)
        then press the Save button, give a name to the shortcut and select the hotkey. Press Ok. Now open a java source and press the hotkey you've selected and you will see your program compiling & running!

        Comment

        • BigDaddyLH
          Recognized Expert Top Contributor
          • Dec 2007
          • 1216

          #5
          There are several free editors that can do this and more, for example TextPad:

          TextPad, text editor, power users, Windows, Server, Nederlands, English, Français, Deutsch, Italiano, Japanese, Polski, Português, Brasileiro, Español, Korean


          It's a basic editor, but it does syntax coloring of Java and comes with menu items to compile and run Java (CTRL+1 and CTRL+2). One of its other features is that it captures compiler error messages in a window, and clicking on a specific error message causes you to jump to the corresponding line in your source code.

          Comment

          • Alexandre Leite
            New Member
            • Jun 2011
            • 1

            #6
            Not free

            TextPad isn't free. It's shareware ("try before you buy").

            Comment

            • Nepomuk
              Recognized Expert Specialist
              • Aug 2007
              • 3111

              #7
              There's an old trick to stop the box closing so that you can read whatever it prints out: Right at the end of the main function add the line
              Code:
              System.in.read();
              That way, it will wait for you to input something before it closes. It's not very aesthetic, I know, but it works.

              Greetings,
              Nepomuk

              Comment

              Working...