Links: http://www.jquerycn.cn/a_27
Again to reprint a good article, didn't think notepad++ so to force
notepad++ Java Development Environment Configuration 1. Installing the JDK
To make it easy to use the tools in the JDK in the console window, you need to append the path to the JDK binary (bin) file in the Windows System environment variable path and update the PATH environment variable by executing the following command in the console window. Set path=.; %path% E:\Program Files\java\jdk1.6.0_02\bin
2. Installing notepad++
notepad++ is a code editor software running under the Windows operating system, capable of syntax coloring for most programming languages, for free software, following the GPL.
3. Configure notepad++3.1 Word Auto-complete function configuration
(What is the word auto-completion: Your source file previously entered words, that token, will be cached, when you enter a character will be displayed, press ENTER to select) notepad++ provides a range of programming-related features such as automatic recognition of source code types, support for automatic indentation, syntax coloring, support for Word/Function name auto-completion, and more. notepad++ default settings support most of the code authoring functionality, and the following will enable notepad++ to support the word auto-complete feature.
Click on the "Settings" menu, select "Preferences" menu item, pop Up "Preferences dialog", select "Backup and AutoComplete", at the bottom of this tab, select "Enable AutoComplete for all inputs" check box, and choose "Word AutoComplete".
3.2 notepad++ Plug-in NPPEXEC implementation console
Dialog, this plugin can complete the Windows console basic functions, such as can be compiled in this window, run Java programs, notepad++ can also run external programs, through menu items and external programs to establish a mapping relationship, support for external programs input parameters and so on.
3.3 Console Dialog As a Java development environment
Show Console Dialog Dialog Click "Plugin" Main menu, select "Nppexec" in its drop-down menu, select "Show Console Dialog" in the level two menu. Console Dialog appears by default at the bottom of the editor.
Editing Java source files
Create a new Java source file Hellonpp.java, and enter the following in the editor:
public class HelloNpp{
public static void main(String[] args){
System.out.println("Hello Notepad++!");
}
}
3.4 Compiling and running Java programs
Notepad has two running code functions, one is run (F5), the other is plugins-nppexec (F6), the former is difficult to achieve, so choose the latter, his command line simulation is very useful.
First press F6, the dialog box that executes the command pops up, and the following three lines are entered in command (s):
cd $(CURRENT_DIRECTORY)
D:\jdk1.6.0_10\bin\Javac.exe $(FILE_NAME)
D:\jdk1.6.0_10\bin\java.exe $(NAME_PART)
This explains the notepad++ environment variable, current_directory represents the current path, which is the path of the currently edited file. Then save as Buildandrun script, which means compile and run. Later F6, you can select the script directly without having to enter the command.
In the console dialog compiler output such as the following list, the green font represents the user input commands and system prompts, the black Font for the console dialog output information, compared with the Windows command-line program output some information, indicating the start and end of the program execution, The last output information indicates that the console dialog is waiting for a new command state.
CD: D:\Java
Current directory: D:\Java
D:\jdk1.6.0_10\bin\Javac.exe "HelloWorld.java"
Process started >>>
<<< Process finished.
D:\jdk1.6.0_10\bin\java.exe "HelloWorld"
Process started >>>
Hello World!
b=true
l=2000
f=1.2
<<< Process finished.
================ READY ================
4. Configure Java External Tools 4.1 notepad++ environment variables
Table 1 These environments defined for notepad++, which can be passed as parameters to external tools
Variable name Meaning Example
FULL_CURRENT_PATH file path name E:\java\HelloNpp.java
CURRENT_DIRECTORY file directory (without file name) E:\javaFILE_NAME File full name HelloNpp.java
NAME_PART file name (excluding ext) HelloNpp
EXT_PART file extension java
4.2 Creating an external tool
These two external tools are Javac and Java, with the addition of a pause feature that allows you to display output information through a console window as you compile or run a Java program.
4.2.1
Javacnpp.bat: Compiles the current Java source file, requires a specified Java source file as a parameter, the screen is paused after the run, and displays the execution result of the compiler. The following is the Javacnpp.bat code:
@echo Onjavac%1pause
4.2.2
Javanpp.bat: Run Java's class binary, you need to specify two parameters, the first parameter is the directory where the class file, the second parameter is the Java program name. The post-run screen is paused, showing the results of the program execution. The following is the Javanpp.bat code:
@echo ONJAVA-CP%1%2pause
4.3 Creating the Javac Menu
This menu item is used to compile the Java source code and generate the class file. Select the main Menu "Run", select "Run ..." in the drop-down menu, or use the shortcut key F5, display the "Run" dialog box, enter the following to run the program name
"E:\Program Files\notepad++\javacnpp.bat" $ (Full_current_path)
Javacnpp.bat for the above created external tool, $ (full_current_path) for the currently edited Java source code file. Click the "Save" button, enter the name of this external tool in the name edit box, such as Javac; in the shortcut dialog box, select the shortcut key to execute this external program, check (CONTROL+SHIFT+J) as a shortcut to compile the Java source code.
4.4 Creating a Java Menu
Java menus are used to run Java programs in the same way as the Javac menu, but each using a different external tool, enter the name of the running program in the Run dialog box:
"E:\Program Files\notepad++\javanpp.bat" $ (current_directory) $ (Name_part)
Javanpp.bat for the above created external tool, $ (current_directory) for Java
The directory where the class file resides, $ (name_part) is the file name (does not include the extension). Click the "Save" button, enter the name of this external tool in the name edit box, such as Java; In the shortcut dialog box, select the shortcut key to execute this external program, and check (Control+shift+x) as a shortcut to run the Java program.
With these two external tools, two menu items are added to the Run menu: Javac and Java, respectively, to compile Java source code and run Java programs. After the code editing area has finished writing, execute the javac command (or use the shortcut key Ctrl+shift+j) to compile the current Java source code file, and then execute Java (or use the shortcut key Ctrl+shift+x) to run the compiled Java program after compiling.
5. Summary
This article describes how to use notepad++ with JDK integration as a simple Java IDE, suitable for beginners with Java. All Java source files are placed in the default package (the package), and if you use the Import/package keyword and follow the configuration described in this article to execute Javac or Java, you will see " Java.lang.NoClassDefFoundError: "Error, recommended for use in console dialog.
Notepad++java Development Environment Configuration