Notepad ++ Java Development Environment Configuration

Source: Internet
Author: User

1. Install JDK
Download JDK 6

Http://developers.sun.com.cn/download/java_se.html

Run the installer and follow the on-screen prompts to install JDK 6. The installation path is as follows:
E:/program files/Java/jdk1.6.0 _ 02
Run the "Command Controller" program and run the following command:
Javac
The system prompts the following error:
'Javac' is not an internal or external command, or a program or batch file that can be run.
To facilitate the use of JDK tools in the console window, you need to append the path of the JDK binary (BIN) file to the Windows environment variable path, and 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 a code editor software running in the Windows operating system. It can color the syntax of most programming languages. It is a free software and complies with GPL. Is:

Http://notepad-plus.sourceforge.net/uk/site.htm

Follow the on-screen prompts to complete the installation.
3. Configure notepad ++
3.1 automatic word population full-featured Configuration
Notepad ++ provides a series of programming-related functions, such as automatic identification of source code types, automatic indentation, syntax coloring, and automatic completion of word/function names. By default, notepad ++ supports most of the code writing functions. The following describes how to enable notepad ++ to support the "Automatic completion of words" function.
Click "Settings" and select "Preferences". The "Preferences" dialog box is displayed. Select "backup and Automatic completion ", select the "enable auto-completion for all input" check box at the bottom of this tab, and select "auto-completion for words ".
3.2 notepad ++ plug-in nppexec implements Console
Dialog. This plug-in can complete basic functions of the Windows console. For example, you can compile and run Java programs in this window. notepad ++ can also run external programs.
The menu item establishes a ing relationship with the external program and supports inputting parameters for the external program.
3.3 console dialog as a Java Development Environment
Show console dialog box
Click the ins main menu, select "nppexec" from the drop-down menu, and select "show console dialog" from the second menu ".
Console dialog is displayed at the bottom of the editor by default.
Edit Java source file
Create a new Java source file hellonpp. Java and enter the following content in the Editor:
Public class hellonpp {
Public static void main (string [] ARGs ){
System. Out. println ("Hello notepad ++! ");
}
}
3.4 compile a Java program
Switch to the console dialog window and compile hellonpp. Java
Java hellonpp. Java
In the console dialog, the compiler outputs 3 results. The black font in the figure indicates the command entered by the user, and the green font indicates the Console
The output information of dialog. Compared with the Windows command line program, the output information indicates the start and end of the program execution, and the output information indicates the Console
The dialog is waiting for a new command.
3.5 run Java program
Switch to the console dialog window and run:
Java hellonpp
Output results in the console dialog window.
4. Configure Java external tools
4.1 notepad ++ Environment Variables
Table 1 defines the environments for notepad ++ and can be passed as parameters to external tools.
Example of variable name meaning
Full_current_path file path name E:/Java/hellonpp. Java
Current_directory directory e:/Java/
File_name file full name hellonpp. Java
Name_part file name hellonpp
Ext_part file extension Java
4.2 create an external tool
The two external tools are javac and Java, and the pause function is added. The output information can be displayed in the console window when Java programs are compiled or run.
4.2.1 javacnpp. BAT: Compile the current Java source file. A specified Java source file must be used as a parameter. After running, the screen is paused and the execution result of the compiled program is displayed. The javacnpp. Bat code is as follows:
@ Echo on
Javac % 1
Pause
4.2.2 javanpp. BAT: To run a Java class binary file, you must specify two parameters. The first parameter is the directory where the class file is located, and the second parameter is the Java program name. After running, the screen is paused and the execution result of the program is displayed. The javanpp. Bat code is as follows:
@ Echo on
Java-CP % 1% 2
Pause
4.3 create a javac menu
This menu is used to compile the Java source code and generate a class file. Select "run" from the main menu, select "Run..." from the drop-down menu, or press the shortcut key F5 to display the "run" dialog box. Enter the following program name:
"E:/program files/notepad ++/javacnpp. Bat" $ (full_current_path)
Javacnpp. bat is the external tool created above. $ (full_current_path) is the currently edited Java source code file.
Click "save" and enter the name of the tool, such as javac, In the name editing box. In the shortcut dialog box, select the shortcut key for executing the program, select (Control + Shift + J) as a shortcut for compiling Java source code.
4.4 create a Java menu
The Java menu is used to run the Java program. The creation method is the same as that of the javac menu, but different external tools are used respectively. In the "run" dialog box, enter the name of the running program:
"E:/program files/notepad ++/javanpp. Bat" $ (current_directory) $ (name_part)
Javanpp. bat is the external tool created above. $ (current_directory) is the directory where the Java class file is located, and $ (name_part) is the file name (excluding the extension ).
Click "save" and enter a name for the tool, such as Java, In the name editing box. In the shortcut dialog box, select the shortcut key for executing the program, select (Control + Shift + x) as the shortcut to run the Java program.

After the two external tools are created, two menu items are added to the "run" menu: javac and Java, which are used to compile the Java source code and run the Java program respectively. Write in the code editing area
After work, execute the javac command (or use the shortcut key Ctrl + Shift + J) to compile the current Java source code file. After compilation, execute Java (or use the shortcut key ).
CTRL + Shift + x) run the compiled Java program.
5. Summary
This article describes how to use Notepad ++ to integrate with JDK as a simple Java
IDE, suitable for beginners with Java. All Java source files are placed in the default package, and no custom package is used.
Import/package keyword. If you execute javac or Java according to the configuration described in this article,"
Java. Lang. noclassdeffounderror: "error. We recommend that you use the console dialog.

 

This article post, original address: http://blog.chinaunix.net/u/19742/showart_1759682.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.