Java JDK + Eclipse + Tomcat Java Web development environment set up

Needs to be done before the school year JavaWeb of their own environment to build, in the build process, encountered little trouble, simply follow the steps and finally completed the task to the teacher for help, then I summarize the implementation of some of the processes in the built environment and experience a little help those comrades who have not completed or there is a need to build a mine, reducing the chance of error.

First, the premise description

Curriculum design object-oriented programming is a Java-based visual development environment, where we use the Eclipse integrated development environment. In this process, we need to download java JDK and the Eclipse development environment to support basic.
In this paper, jdk-8u191-windows-x64 and eclipse-jee-oxygen-2- win32-x86_64 example.

Second, the environment configuration

(A) Java: JDK installation and configuration environment

(1) JDK Download

https://www.oracle.com/java/technologies/javase-jdk8-downloads.html
Note: Here we can download Java8 version, the highest version is Java13, but does not recommend using the latest version, as some earlier versions of Internet integrated environment does not support the latest version, if you will encounter in the reference library functions code on the network or grammar problems.

Where x86 for 32-bit operating system, x64 for 64-bit operating system; not here 32 can not be used on 64-bit machine, but will be called into a program (86)
files, and subsequently also download the corresponding 32-bit version of eclipse.

Next, as shown:

Here we must pay attention to choose to accept the agreement.

(2) JDK mounted to Example java1.8

Open the downloaded file to install JDK, direct default installation, the installation process may modify the JDK installation address.
Here Insert Picture Description
Here Insert Picture Description
jre

Click OK to install.

Click Next to display the progress of the installation.

Here Insert Picture Description

The installation is complete, click Close.

(B) Eclipse download and install

(1) Eclipse Download:

https://www.eclipse.org/downloads/packages/
这里主要是用于Java web开发,所有我们选择Java EE
Here Insert Picture Description
或是在右侧找到早期版本进行下载
Here Insert Picture Description

(2)Eclipse下载安装:

在Eclipse下载页选择右侧正确的系统类型后(右击计算机,选择属性,可以查看电脑的系统类型是32位还是64位),直接下载到电脑,解压到电脑盘中即可。
as the picture shows

选择使用的版本 eclipse-jee-oxygen-2-win32-x86_64,进入相应的文件夹

双击eclipse 图标,显示设置目录,指定工程目录。

等待片刻,出现如下图示,第一次打开时间会稍长。

成功则出现如下界面,若打开不成功请检查JDK的安装。

点击WorkBench,进入编辑工作窗口。

as the picture shows
以上这些,只要按照步骤来做,一般情况下是不会出错的。
**

(三)基于Tomcat的Web开发需要配置环境变量

**
前面的Java+eclipse集成开发环境配置是不需要配置环境变量的,但是要实现Web开发就需要配置环境变量。

(1)Java环境配置

基于Tomcat的Web开发需要配置环境变量(也有的版本不需要,网上也有免搭建环境的),由于配置环境有利于深入理解TOmcat的运行原理以及Web开发,所以这里详细描述一下。

  • 在计算机属性中,选择左上方的“高级系统设置”,并在弹出框中选择“高级”,下方列表中会有“环境变量”选项,点击“环境变量”,弹出环境变量设置的窗口。
  • 环境变量中我们主要是在系统变量里面配置java环境,首先我们在系统变量中选择“Path”变量,点击编辑(或双击该变量),在编辑窗中新增java“bin”路径和使用的jre 路径,如下所示:
    C:\Program Files\Java\jdk1.8.0_191\bin;
    C:\Program Files\Java\jre1.8.0_191\bin;

    (注意哦:这里的应该是你的真实的路径,具体放在哪里看你盘符的具体情况,这里只是个例子)
  • 接下来在系统变量中新建一个CLASSPATH变量,点击新建,在新建系统变量弹出框中变更名处输入“CLASSPATH”,在变量值中输入java中lib目录下的tools.jar和dt.jar路径,如下所示:
    .; (此处不能省略)
    C:\Program Files\Java\jdk1.7.0_05\lib\tools.jar;
    C:\Program Files\Java\jdk1.7.0_05\lib\dt.jar;

    (注:地址前或地址最后必须有“.;”,其中“.”表示各目录的根目录)

验证环境变量配置是否成功:进入cmd键入java ,出现如下界面

Here Insert Picture Description

然后输入“javac“,回车,会出现如下图所示内容:

Here Insert Picture Description
上面两个界面均出现说明Java配置成功!!!!

注意: 一定注意使用英文的输入法,win 10 系统可能在配置classpath时会出问题,将JAVA_HOME换成绝对路径试一下。若是打不开命令行,可将下列语句拷贝入文件,存为cmdhere.reg;然后双击该文件,加载注册表可在桌面点击右键出现cmdhere 弹出菜单。
REGEDIT4
[HKEY_CLASSES_ROOT*\shell\cmdhere]
@=“Cmd&Here”
[HKEY_CLASSES_ROOT*\shell\cmdhere\command]
@=“cmd.exe /c start cmd.exe /k pushd “%L\…””
[HKEY_CLASSES_ROOT\Folder\shell\cmdhere]
@=“Cmd&Here”
[HKEY_CLASSES_ROOT\Folder\shell\cmdhere\command]
@=“cmd.exe /c start cmd.exe /k pushd “%L””
以上配置是Java开发的基本路径配置;若想进行web开发除了以上配置之外,还需为TOMCAT配置下面的环境变量
新建变量JAVA_HOME
其值为:C:\Program Files\Java\jdk1.7.0_05 (后面不要分号;)
新建变量JRE_HOME
其值为:C:\Program Files\Java\jre7 (后面不要分号;)

如果不配置 则会出现以下提示:
Here Insert Picture Description

(2)Tomcat环境配置(Tomcat9.0.8)

  • Tomcat下载地址:https://tomcat.apache.org/download-90.cgi
    建议下载免安装版apache-tomcat- .zip
    Here Insert Picture Description
    注意版本要和自己的JDK匹配,也要和操作系统匹配
    Here Insert Picture Description
    Here Insert Picture Description
    Here Insert Picture Description
    选择合适版本下载即可。

  • Tomcat环境变量配置:
    1)在计算机属性中,选择左上方的“高级系统设置”,并在弹出框中选择“高级”,下方列表中会有“环境变量”选项,点击“环境变量”,弹出环境变量设置的窗口。
    2)环境变量主要是配合Eclipse中的windows—>perferences下Tomcat的路径方便使用。
    ①我们在系统变量中选择系统变量path,然后点击编辑(也可以双击path),在弹出框的变量值中输入Tomcat的bin路径:
    J:\Tools\apache-tomcat-9.0.8\bin;
    选中系统变量CLASSPATH,添加Tomcat中servlet-api.jar路径: J:\Tools\apache-tomcat-9.0.8\lib\servlet-api.jar;
    ②创建两个新的系统变量 CATALINA_BASE其值为(Tomcat的安装路径或工作路径)(原来是用的是 TOMCAT-home,在Tomcat 4 以后,采用了新的Servlet容器Catalina,所以环境变量的名字也改为了CATALINA_HOME。)
    J:\Tools\apache-tomcat-9.0.8后面不要分号;
    CATALINA_HOME,变量值为(必须是Tomcat的安装路径J:\Tools\apache-tomcat-9.0.8后面不要分号;
    ③在Tomcat安装目录bin文件中找到startup.bat双击,启动Tomcat服务器(这个我当初在bin目录下只找到了startup并双击了它,没有找到有后缀的)

    记住,添加完路径之后一定要将其保存,保存,保存!!!

    ④打开浏览器,在地址栏输入: http://localhost:8080(或http://127.0.0.1:8080),
    如果打开页面如下图所示时,则表示Tomcat环境配置完成。
    Here Insert Picture Description
    如果你没有对你的路径进行保存就出不来(我当初就是没有保存,怎么着都出不来,但是发现路径和安装的什么的都没有错误,最后问老师才知道原来是路径没有保存,这是血的教训!!!!)

如果出现闪退,请到安装目录查看日志文件。
Here Insert Picture Description

三、Eclipse中web开发的基本设置

(一)Eclipse中Tomcat环境配置

  • 1)打开Eclipse,选择Window—>perferences,在弹出的框中选择左侧的Server目录下的Runtime Environments,如下图所示:
  • Here Insert Picture Description 2)在弹出框选择右侧的Add,然后在Apache目录下选择安装的Tomcat版本,这里选择Apache Tomcat9.0,如下图所示:
  • Here Insert Picture Description
    点击Next,在弹窗中设置apache-tomcat-9.0.8的安装路径(点击Browse,选择安装文件夹),并在下方选择安装的jdk版本,如下图所示:
    Here Insert Picture Description
    点击Finish完成Runtime Evironments配置,点击ok,完成Tomcat的基本配置。

(二)运行HelloWorld!

(1)创建Web工程

  • 选择File—>New—>Other,在弹出框中选择Web—>Dynamic Web Project,点击Next,弹出工程创建页面,在Project name中输入HelloWorld,然后点击Finish,完成HelloWorld工程创建。
  • Here Insert Picture Description
    Here Insert Picture Description

(2)新建index.jsp文件

  • 1) WebConnent files in the selected directory HelloWorld project folder, right click and select New -> JSP File , in the File name input pop-up box on the right side of index.jsp , click Finish , to complete the creation of index.jsp.
    Here Insert Picture Description
  • 2) Double-click to open index.jsp, in <body>and </body>between the input
<h1>Hello World ! This is my first JSP page!</h1>

Click the top left corner to save.
Here Insert Picture Description

  • 3) Select the HelloWorld project, right click and select the Run AS -> the Run ON Server , the pop-up box, select the corresponding versions of Tomcat have Server, click Finish, run HelloWorld project. If the content as shown below occurs, the environment configuration is successful.
  • Here Insert Picture Description

The detailed procedure is roughly like this, is not too difficult, it is easy to overlook some places, if a mistake will be very troublesome.

Released five original articles · won praise 0 · Views 53

Guess you like

Origin blog.csdn.net/qq_45804925/article/details/104550709