Turn: [Notepad ++ configuration Java development environment]

 

1. Install the JDK

In order to facilitate the use of the JDK tools in the console window is necessary to add the Windows system PATH environment variable in the path of the file where the JDK binaries (bin), execute the following command in the console window, update the PATH environment variable. set path =;% path%; E:. \ Program Files \ Java \ jdk1.6.0_02 \ bin

2. Install Notepad ++

Notepad ++ is running under a Windows operating system software code editor, syntax coloring can be performed on most of the programming language for the free software, follow the GPL.

3. Configure Notepad ++

3.1 word auto-completion function configuration

(What is the word automatically fill the whole: previously entered your source file word that token, will be cached, when you enter a message will be displayed, press Enter to select) offers a range of programming related functions Notepad ++, The automatic source type identification, auto indentation, syntax coloring, supports word / function name auto-complete functions. Notepad ++ supports most of the default settings coding function, the following will make Notepad ++ supports "automatic word completion" feature.

Click the "Settings" menu, select "Preferences" menu item to bring up the "Preferences dialog", select the "Backup and auto-complete", select the tab at the bottom of this page "All inputs are enabled automatically" check box, and select "word completion."

3.2 Notepad ++ plugin NppExec achieve Console

Dialog, this plugin can perform basic functions of Windows console, as can be compiled to run Java programs in this window; Notepad ++ can also run an external program, establish the mapping via the menu item and external programs, support the input parameters for the external procedures.

3.3 Console Dialog as a Java development environment

Display Console Dialog box click on the "plug-in" Main Menu, select "NppExec" in its drop-down menu, select "Show Console Dialog" in the secondary menu. Console Dialog editor appears by default in the bottom.

Edit Java source files

Create a new Java source file HelloNpp.java, enter the following in the editor:

public class HelloNpp{
    public static void main(String[] args){
        System.out.println("Hello Notepad++!");
    }
}

3.4 compile and run Java programs

notepad two functional operation code is a Run (F5), and the other is Plugins -> NppExec (F6), is difficult to achieve with the former, the latter, the command line is very easy to simulate him.

First press F6, the dialog box will pop up to execute the command, enter the following three lines in the 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)

Here to explain notepad ++ environment variables, CURRENT_DIRECTORY represents the current path is the path of the currently edited document. Then save as BuildAndRun script, expressed compile and run. After the F6, you can directly select the script, instead of typing commands.

In the Console Dialog compiler output as shown in Listing, green font indicate user input commands and system prompts, output black font for Console Dialog, multi-output compared to some of the information with the Windows command line program represents the start of program execution and the end, the final output information indicates Console Dialog in the state of waiting for a new command.

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. placed Java external tool

4.1 Notepad ++ environment variables

Table 1 is defined Notepad ++ these environments can be passed as a parameter to the external tools

Variable Name Meaning examples
FULL_CURRENT_PATH file path name E: \ java \ HelloNpp.java
CURRENT_DIRECTORY file directory (without the file name) E: \ java \
Full name HelloNpp.java file FILE_NAME
NAME_PART file name (without ext) HelloNpp
EXT_PART file extension java

4.2 Creating an external tool

Both external tools javac and java, increase the pause function, you can display output from the console window when you compile or run Java programs.

4.2.1

javacnpp.bat: Compile the current Java source file, you need to specify a Java source file as an argument, after running the screen is paused, and displays the results of the implementation of the compiler. The following is javacnpp.bat Code:

@echo on
javac %1
pause
4.2.2

Javanpp.bat: running Java class binary files, you need to specify two parameters, the first parameter is the directory where the file class; second parameter is a Java program name. After running the screen is paused, displaying the results of program execution. The following is javanpp.bat Code:

@echo on
java -cp% 1% 2
pause

4.3 Creating javac menu

This menu item is used to compile the Java source code to generate class files. Select Main Menu "Run", select "Run ..." in the drop-down menu or use the shortcut F5, display the "Run" dialog box, enter the following to run the program name

"E:\Program Files\Notepad++\javacnpp.bat" $(FULL_CURRENT_PATH)

External tool created for javacnpp.bat above, $ (FULL_CURRENT_PATH) for the Java source code file currently being edited. Click the "Save" button, in addition to the name of the tool, such as javac enter the name of the edit box; the shortcut dialog box, select this external program execution corresponding shortcut key, select (Control + Shift + J) as compiled Java source code Shortcut.

4.4 Creating java menu

java java menu to run the program, the way to create a menu with javac same, but each uses a different external tools, enter the program name to run in the "Run" dialog box:

"E:\Program Files\Notepad++\javanpp.bat" $(CURRENT_DIRECTORY) $(NAME_PART)

External tool created for javanpp.bat above, $ (CURRENT_DIRECTORY) for Java

Directory class files are located, $ (NAME_PART) for the file name (does not include extension). Click the "Save" button, enter the name of the edit box in the name of this external tool, such as java; shortcut dialog box, select this external program execution corresponding shortcut key, select (Control + Shift + X) as a shortcut to run Java programs the way.

After the establishment of the two external tool, in the "Run" menu will add two menu items: javac and java, were used to compile the Java source code and run Java programs. After compiling and after the implementation of java (or use the shortcut Ctrl + Shift + X) to run the compiler; after the completion of the preparation in the code editor, executive javac command (or use the shortcut Ctrl + Shift + J) is currently compiling Java source code file Java programs.

5. Summary

This article describes how to use Notepad ++ integrated with the JDK as a simple Java IDE, Java suitable for beginners. When all of the text in the Java source files are placed into the package the default (package) is not used to customize the package (package), if using the import / package key, as described herein, or configured to perform javac java, it will run there will be "java.lang.NoClassDefFoundError:" error recommended Console Dialog execution.

Transfer: http://www.jquerycn.cn/a_27

Guess you like

Origin www.cnblogs.com/fangyanr/p/11957497.html