Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build Java Development Environment

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This "how to build Java development environment" article, the article sample code is introduced in great detail, with a certain reference value, interested friends must refer to, for "how to build Java development environment", Xiaobian sorted out the following knowledge points, please follow the pace of the editor step by step slowly understand, then let us enter the topic.

Operating system

Use Windows10. Stable, beautiful, good performance, compatibility is also good.

The built-in software is also very good, the Edge browser has made remarkable progress, and IE11 is the highest version of the IE series. Pinyin and five-stroke input methods are easy to use, have their own antivirus software, and can even connect to mobile phones. A lot of software doesn't need to be installed any more, but this may not be good news for the companies that do it.

Decompression software with 7-zip, text editor with notepad++, from then on the computer quiet.

More importantly, with the popularity of Windows10, WEB designers no longer have to be compatible with various versions of IE, but can boldly use the new features of html5, resulting in higher development efficiency and better user experience. If you need to test versions below IE10, you can use a virtual machine.

Set to show hidden files, folders, and display extensions. Right-click the start menu-Control Panel (View: mini icon)-File Explorer options-View, select to show hidden files, folders and drives, and uncheck the extension of the known file type. The extension of hidden files and known file types is not displayed by default, mainly to prevent rookies, delete important files or mistakenly change file extensions. But for programmers, you need to see all files clearly, including the full file name.

Mysql "> MySQL

Use MySQL5.7. Use the workbench client tool provided by MySQL directly.

Install MySQL Server X64, MySQL Workbench, and MySQL Documentation (optional).

It is possible to install vcredist_x64.exe before you can install MySQL Workbench.

Download address: http://dev.mysql.com/downloads/

JDK

Use JDK8. If you need to be compatible with JDK6 and JDK7, you can install multiple versions of JDK, usually the lower version before the higher version. Select 64 bits. JDK can be installed through the EXE file, or you can directly copy the installed JDK folder.

Download address: http://www.oracle.com/technetwork/java/javase/downloads/index.html

To avoid potential and unknown problems, do not install JDK in Chinese or spaces, do not install it in the default C:\ Program Files directory, you can install it in a directory similar to C:\ java.

Set the environment variable JAVA_HOME, such as C:\ java\ jdk8, which must be set. Otherwise, the unzipped version of Tomcat, Eclipse and other software can not run, and the startup interface flashes by, usually because JAVA_HOME is not set correctly. Run echo% JAVA_HOME%, on the command line if the correct path is displayed, the setting is successful.

Set the environment variable Path, such as% JAVA_HOME%\ bin, at the end of a single-line Path, separated by a semicolon, such as...;% JAVA_HOME%\ bin; the new version of Windows10 supports multiline path values, there is no need to add a semicolon. When you install JDK8, the installer sets it up automatically, not manually. Run java-version on the command line, and if the version information is displayed, the setting is successful. When jdk is installed, it is possible to automatically set C:\ ProgramData\ Oracle\ Java\ javapath to Path, which points to jre, which may cause problems in some cases, such as errors such as You need to run build with JDK or have tools.jar on the classpath in maven. So% JAVA_HOME%\ bin should be set before C:\ ProgramData\ Oracle\ Java\ javapath, or delete the item.

Maven

Use Maven-3.2.5. A later version of Maven3.3 requires a later version of JDK7 (not compatible with JDK6), and a lower version of Maven may not support JDK8.

Download address: http://maven.apache.org/download.cgi

Set the environment variable MAVEN_HOME, such as C:\ maven\ apache-maven-3.2.5. Run echo% MAVEN_HOME%, on the command line if the correct path is displayed, the setting is successful.

Set the environment variable Path, such as% MAVEN_HOME%\ bin. Run mvn-v on the command line, and if the version information is displayed, the setting is successful.

Eclipse

Use eclipse-jee-mars-2-win32-x86_64.

Download address: http://www.eclipse.org/downloads/eclipse-packages/

Sets the file encoding. Window-> Preferences-> General-> Workspace, set Text file encoding-Other to UTF-8. If you do not set this item, the Chinese in Java and other documents may appear as garbled.

Modify the JSP encoding. Window-> Preferences-> Web-JSP Files,Encoding is UTF-8.

Modify the font. If the Chinese font in the Java file is very small, you can set Window-> Preferences-> General-> Appearance-> Colers and Font-> Basic-> Text Font, select Courier New; or Consolas as the font, and change the script Western European characters to Central European characters.

Turn off automatic validation files. Window-> Preferences-> Validation, uncheck all the boxes in the Build column. The syntax check of Eclipse is not perfect, and many correct grammars are misjudged as wrong grammars, resulting in a large number of false positives. This is the case when many files that work correctly show errors in Eclipse.

Close Updating Error Reporting Database. Window-> Preferences-> General-> Startup and Shutdown, uncheck Eclipse Automated Error Reporting.

Set up the JRE. Window-> Preferences-> Java-> Installed JREs, click Add to add JDK7 (such as C:\ java\ jdk7) and JDK6 (such as C:\ java\ jdk6). If you need to generate classes for JDK6 or JDK7, you need to set this item, otherwise Eclipse will give you a warning. You also need to set the path of JDK8 to the JDK directory, which is set by default to the JRE directory, which may make errors when running maven.

Set up the Maven. Window-> Preferences-> Maven-> Installations, click Add to add Maven3.2.5 (such as C:\ apache-maven-3.2.5). After clicking Finish, check apache-maven-3.2.5 as the default Maven.

Eclipse plug-in

Eclipse plug-in Market address: http://marketplace.eclipse.org/

Click Help-> Eclipse Marketplace to find the plug-in you need.

Install the Properties Editor plug-in. Enter Properties Editor in the Help-> Eclipse Marketplace,Find box to search, find the plug-in named Properties Editor, and click Install. Can automatically translate Chinese in properties files. If you do not install this plug-in, the Chinese in the properties file will be directly displayed as code similar to\ u8888.

Install the FreeMarker IDE plug-in. Enter FreeMarker IDE in the Help-> Eclipse Marketplace,Find box to search, find the plug-in named FreeMarker IDE from JBoss Tools, and click Install.

Install the YAML plug-in. Enter YEdit in the Help-> Eclipse Marketplace,Find box to search, find the plug-in named YEdit, and click Install.

Maven warehouse

In China, it is very slow or even impossible to connect to the central Maven repository. Without using domestic Maven repository images, it is almost impossible to use Maven for development smoothly.

If downloading the dependency package is very slow or appears when starting the project

Failed to execute goal on project xxx:Could not resolve dependencies for project com.jspxcms:xxx:Failure to find xxx.xxx:xxx:jar:xxxxxx in https://repo.maven.apache.org/maven2

An error like this indicates that the dependency package cannot be downloaded from the Maven central library https://repo.maven.apache.org/maven2.

Because Maven repository images consume a lot of traffic and are almost impossible to make a profit. It is not a thing to install a 100m bandwidth at home, but it is very expensive to give the server 100m bandwidth, and the 100m bandwidth is a drop in the bucket for Maven warehouse images, so domestic Maven warehouse images have collapsed one after another. But now the rich and powerful Ali Yun has taken on this important task, bringing good news to the vast number of Chinese programmers. The company still suggests to build Maven private server, don't take down Ali Yun.

Using Aliyun's Maven image repository, modify the settings.xml configuration file in the maven installation directory as follows:

Central * Nexus Aliyun http://maven.aliyun.com/nexus/content/groups/public/ nexus nexus-repo http://maven.aliyun.com/nexus/content/groups/public/ true true nexus-repo http://maven.aliyun .com / nexus/content/groups/public/ true true nexus

The default directory of the local warehouse is C:\ Users\ myname\ .m2\ repository. If the .m2 folder does not exist, you need to execute mkdir C:\ Users\ myname\ .m2 on the command line to create the directory (change myname to the actual user name), which may not be created directly on the graphical interface. The folder at the beginning. The operating system does not show hidden files and. At the beginning of the file, you need to set up to show hidden files and folders.

Create a database and import the project

Follow the steps in the source package README.md file. The file is in markdown format and can be opened directly in notepad. The content of each version of README.md will be different. The following example is given for reference. Note: if you use this step directly, it will not start correctly. Please follow the README.md file under the source code package:

Create a database. If MySQL is used, the character set is selected as utf8 or utf8mb4 (more special characters are supported, recommended).

Execute the database script. The database script is in the database directory.

Import the maven project in eclipse. Click the eclipse menu File-Import and select Maven-Existing Maven Projects. After you have created the maven project, you will start downloading third-party jar packages (such as spring, etc.) from the maven server. It will take some time. Please wait patiently.

Modify the database connection. Open the / src/main/resources/custom.propertis file and modify the values of jdbc.url, jdbc.username, and jdbc.password according to the actual situation.

Run the program. In eclipse, right-click the project name, select Run as-Maven build...,Goals to fill in tomcat6:run or tomcat7:run, and then click Run.

Access the system. Foreground address: http://localhost:8080/, mobile station address: http://127.0.0.1:8080/; background address: http://localhost:8080/cmscp/index.do, user name: admin, password: empty.

Context path

The program is usually deployed in the Tomcat root directory, and the home page access address is similar to http://www.mysite.com/ http://localhost/ http://localhost:8080/. In some special situations, such as the default Tomcat startup mode of Eclipse (non-maven mode), the program may be deployed under a certain path, and the home page access address is similar to http://www.mysite.com/jspxcms/ http://localhost/mysite/ http://localhost:8080/jspxcms/. When visiting the foreground of the website, the style cannot be displayed normally. You can set the context path in the backend system-system settings, similar to / jspxcms, where slash / cannot be omitted, and jspxcms is the path to the deployment directory. If in the development environment, it is usually the project name.

The development environment should avoid using the context path, unless the website is also deployed to the appropriate path, otherwise the images uploaded in the development environment cannot be displayed normally when deployed to the formal environment. Because when uploading a picture, the image address will have the information of the context path.

Eclipse's default tomcat startup method (non-maven method) deploys the program to a specific directory and then starts it. It does not start tomcat directly in the directory where the project is located. Images uploaded in the development environment (including templates added and modified through the system backend) are also saved in a specific deployment directory, not in the directory where the program is located. When the Eclipse source code or file is modified, the program will be redeployed automatically, and the previously uploaded images will be emptied. If you find that the pictures uploaded in the development environment are suddenly missing, this is probably the reason.

To sum up, it is strongly recommended to start the program in maven mode.

What are the advantages of Java. Simple, as long as understand the basic concepts, you can write applications suitable for a variety of situations; 2. Object oriented; 3. Distributed, Java is a network-oriented language; 4. Robust, java provides automatic garbage collection for memory management to prevent programmers from making mistakes when managing memory. ; 5. Security, Java used in the network and distributed environment must prevent the invasion of viruses. 6. Architecturally neutral, as long as the Java runtime system is installed, it can run on any processor. 7. Portability, Java can be easily ported to different machines on the network. 8. Interpretation execution, Java interpreter directly interprets and executes Java bytecode.

These are all the contents of the article "how to build a Java Development Environment". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report