Construction of Javaweb development environment based on idea

Source: Internet
Author: User
Tags java se

Construction of Javaweb development environment based on idea

  • Construction of Javaweb development environment based on idea
    • JDK download installation Configuration environment variables
      • Download
      • Installation
      • Configuring Environment variables
    • Download install activation using IntelliJ idea
      • Download
      • Installation
      • Activated
        • 1 Text editor first open the Hosts file on the bottom line to add the following address
        • 2 getting the latest activation code from LAN Yu
        • 3 Enter the activation code on the activation page
      • Use
        • 1 Creating a common Java project
        • 2 Creating a Web project
    • Download installation configuration Tomcat
      • Download
      • Installation
      • Configuration
        • Configuring the Tomcat environment variable
        • Idea Project configuration Tomcat
      • Problems
        • Tomcat Port is occupied
        • Idea Console Chinese garbled
    • Download installation configuration Maven
      • Download
      • Installation
      • Configuration
        • Configuring MAVEN Environment variables
        • Configuring the local MAVEN warehouse repository
        • Idea Project configuration Maven
    • Download installation Configuration SVN
      • Download
      • Installation
      • Idea Configuration
    • Download installation configuration Git
      • Download
      • Installation
      • Configuration
    • If you have any questions, please help me.

JDK download, install, configure environment variable download:

JDK1.8 Download path is: Java SE development Kit 8 Downloads

Installation:

Double-click to install the next step. Because installing the JDK automatically installs the JRE, the window that pops up the JRE during installation can be turned off.

To configure environment variables:

Right-click the 我的电脑 icon and select 属性 .


If there is no icon on your computer desktop 我的电脑 , press Window + E to open File Explorer, and the left side has my Computer icon.
Click 高级系统设置 环境变量 新建 , fill in the variable name, and click on the value of the variable 确定 .

The variable names and variable values that need to be added are:

Variable name: JAVA_HOME
Variable Value:C:\Program Files\Java\jdk1.8.0_131

Variable name: CLASSPATH
Variable Value:.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;

Select path under System variables, click Edit, and then confirm the save by adding the following at the end of the variable value:

%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;
    • 1

Configure environment variables Next Verify success:
Window+ R , enter and cmd Click OK to open the Command window, if the correct input java will display the following information:

The input javac will prompt the following information:

Download, install, activate, use IntelliJ idea download:

Official website: https://www.jetbrains.com/idea/download/#section =windows

Note Select the version that corresponds to your operating system. IntelliJ idea is divided into the "ultimate" Community Edition area, the difference is as follows

Do not differentiate between 32-bit and 64-bit, only one installation package.
The flagship feature is free to try.

Installation:

The next step.
Note here that the icon added to the desktop is selected,

Activated:

Funds allowed please support genuine: Purchase address

The following activation codes are from: Lan Yu

1, the text editor first open the Hosts file on the bottom line to add the following address:

Hosts file path: C:\Windows\System32\drivers\etc\hosts
Add an address on the bottom line:0.0.0.0 account.jetbrains.com

If you are prompted for no permission action, you will need to add permissions to the current Windows user to edit the file:
As shown in the image below, modifying that item in the user's permissions list does not have a √.

If you do not know the current logged on user can do the following:

    • Press Window + R to enter the cmd Open cmd Command window.
    • Input quser Press ENTER.

2. Get the latest activation code from LAN Yu

3. Enter the activation code on the activation page

After installation, the first idea will automatically pop up the activation page, if you want to enter the activation code activation during the trial process can do the following:

Enter the activation code by clicking OK.

Use: 1, create a common Java project:

You can create from a template (either by adding the main class and the Main method) or by creating an empty project, which you choose to create from the Hello World template.

Fill in the project name and path, the package where the main class resides.

Setup Project:

Note: If the console run-time console throws errors Error:java:无效的源发型版本:x.x , be aware that the language level in step 4 may be greater than the JDK version.

Run:

Debugging:

2. Create a Web project

Download, install, configure Tomcat downloads:

Official website: http://tomcat.apache.org/
Select the desired version for download.
For example I want to download Windows platform 64-bit TOMCAT9:

Installation:

Download the file is a compressed package, unzip can be used.

Configuration: Configuring the Tomcat environment variable

Similar to configuring a JDK environment variable: Create a new variable under a system variable,

    • Variable name:CATALINA_HOME
    • Variable Value: Tomcat extract directory, Bin's parent directory, asD:\tools\apache-tomcat-9.0.0.M22

After the variable path is added after the %CATALINA_HOME%\bin; save;

    • Press Window + R to open, enter the cmd Open cmd Command window.
    • Enter and startup then press ENTER. Configuration no problem will start the Tomcat service.

Then open the browser input http://localhost:8080/, if the following page appears to indicate that the tomcat environment is configured correctly.

Idea Project configuration Tomcat

1, under the Javaweb project click Edit Configuration :

2, click in the Pop-up window + , the first configuration of the Tomcat list has no Tomcat Service options, you need to click the bottom xx items more(irrelevant)... , then you can see the Tomcat Service options. Select Tomcat Service the option inside Local .

3, give the service a name (any), configure the Tomcat decompression directory.

4. Switch to Deployment tab and add Artifacts .


5, switch back Service to the tab again, the Parameters panel will have a slight change.

6. After configuring the parameters you can start Tomcat, run and debug similar to common Java engineering.


FAQ Tomcat Port is occupied

Sometimes you'll be prompted when you start Tomcat Address localhost:8080 is already in use .


1, the first case is 8080 port is occupied by other services, the solution:
Locate the Tomcat解压目录\conf\server.xml file, open it with a text editor, search 8080 , find


Modify port="8080" , change a port number for example port="8090" .
To test whether a new port number is occupied, you can do the following:

    • Press Window + R to enter the cmd Open cmd Command window.
    • Input netstat -aon|findstr "端口号" Press ENTER.

2. The second case is that although the port is 8080 not occupied, a Tomcat service has been opened elsewhere.
Workaround: Just close the Tomcat service.

    • Locate Tomcat解压目录\bin\shutdown.bat the file and double-click Execute.

Another `Tomcat解压目录\bin\startup.bat file is to open the Tomcat Service command.

Idea Console Chinese garbled

Sometimes the idea console output in Chinese will appear garbled situation:


Right click on the idea icon, select 打开文件所在的位置 , find the following file:

    • Idea.exe.vmoptions (32-bit version)
    • Idea64.exe.vmoptions (64-bit version)

My file path is:

?C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2017.1\bin\idea.exe.vmoptions
    • 1

I'm using a 64-bit version, so open with a text editor idea64.exe.vmoptions and add the following code on the bottom line:

-Dfile.encoding=UTF-8
    • 1

At the same time, in the Tomcat parameter: VM options Add the same code:

-Dfile.encoding=UTF-8
    • 1

Download, install, and configure MAVEN downloads:

Official website: http://maven.apache.org/download.cgi

Installation:

Unzip is ready to use.

Configuration: Configure MAVEN environment variables

Configuring the MAVEN environment variable is similar to configuring the JDK environment variable:
-Variable Name: MAVEN_HOME
-Variable Value: Maven unzip directory, Bin's parent directory, asD:\tools\apache-maven-3.5.0

After the variable path is added after the %MAVEN_HOME%\bin; save;

    • Press Window + R to open, enter the cmd Open cmd Command window.
    • Enter and mvn -v then press ENTER. The MAVEN version information appears stating that the MAVEN environment is configured correctly.

Configuring the local Maven warehouse (repository)

The local warehouse location that the system uses by default is: %USER_HOME%\.m2\repository ,
The Settings.xml file location is: %USER_HOME%\.m2\settings.xml ,

After testing, if the local does not have both paths using the system default settings, it will be created automatically %USER_HOME%\.m2\repository %USER_HOME%\.m2\settings.xml , and the file can be created manually.

If you want to use a custom setting, you need to do the following:

    1. %MAVEN_HOME%under new repository folder (location not enforced).
    2. Open the file with a text editor, %MAVEN_HOME%\conf\settings.xml search localrepository , and add the following code below (the absolute path to the repository folder you just created):
<localRepository>D:\tools\apache-maven-3.5.0\repository</localRepository>
    • 1

Idea Project configuration Maven

1, in the idea software anywhere press Ctrl + Alt + S open Settings Settings window,
Enter the "Maven" return search in the ① location. Settings Maven home directory , set as Maven unzip directory (top level directory in Bin folder)

2. Tick the two Override checkboxes and set the User settings file setting.xml file as just configured.

Download, install, configure SVN download:

Little Turtle svn website download: https://tortoisesvn.net/downloads.html

Installation:

Various next ...
Only this place to note:

Go to the installation directory \bin\ to see if there are any svn.exe files, if not the installation process may not be installed command line client tool , that is.

There's a trick to searching a file in a folder: Click a file in the folder, make the focus drop in the folder, and enter the file name directly on the keyboard.

Idea Configuration

In the idea software anywhere press Ctrl + Alt + S open Settings Settings window, search sub , find Subversion , will be command line client set to just install the Small turtle directory \bin\svn.exe.

Download, install, and configure Git downloads:

Official website: https://git-scm.com/downloads

Installation:

Always next, save the default.

Configuration:

1, in the idea software anywhere press Ctrl + Alt + S open Settings Settings window, search git, configure the git.exe path.

2. Set up a GitHub account in idea.

3. Cloning project from GitHub repositories

On the first page clone:

In a project, clone:

Select the project to clone from repositories:

Clone out of the project such as:

Construction of Javaweb development environment based on idea

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.