1. Overview
1.概述
GlassFish Server is an open-source application server for developing and deploying Java Enterprise applications. Also, it provides support for web containers, load balancing, an administrative console for configuration and management, etc.
GlassFish Server 是一款开源 应用服务器,用于开发和部署 Java 企业应用程序。此外,它还支持 网络容器、负载平衡、用于配置和管理的管理控制台等。
In this tutorial, we’ll learn step-by-step the process for configuring GlassFish Server within Eclipse IDE.
在本教程中,我们将逐步学习在 Eclipse IDE 中配置 GlassFish Server 的过程。
2. GlassFish Server in Eclipse IDE
2.Eclipse IDE 中的 GlassFish 服务器
To configure the GlassFish server in Eclipse IDE, we must install the Eclipse IDE for Enterprise Java and Web Developers on our machine.
要在 Eclipse IDE 中配置 GlassFish 服务器,我们必须在计算机上安装 Eclipse IDE for Enterprise Java and Web Developers。
The Eclipse IDE for Enterprise Java Developers extends the functionality of the Standard Eclipse IDE. It has additional tools to bootstrap the Java EE/Jakarta EE application.
Eclipse IDE for Enterprise Java Developers 扩展了标准 Eclipse IDE 的功能。它具有额外的工具来引导Java EE/Jakarta EE 应用程序。
2.1. GlassFish Tool
2.1.玻璃鱼工具
Eclipse IDE for Enterprise Java Developers, by default, is bundled with tools to set up popular web servers like Tomcat, WebSphere, etc. However, the GlassFish Tool isn’t installed by default.
Eclipse IDE for Enterprise Java Developers 默认捆绑了用于设置常用 Web 服务器(如 Tomcat、WebSphere 等)的工具。但是,默认情况下并未安装 GlassFish 工具。
The Oracle Enterprise Pack for Eclipse contains Eclipse GlassFish Tools. Let’s add the plugin repository “http://download.oracle.com/otn_software/oepe/12.2.1.8/oxygen/repository/dependencies/” to Eclipse IDE to install the GlassFish tool.
Oracle Enterprise Pack for Eclipse 包含 Eclipse GlassFish 工具。让我们将插件库”http://download.oracle.com/otn_software/oepe/12.2.1.8/oxygen/repository/dependencies/“添加到 Eclipse IDE 以安装 GlassFish 工具。
First, let’s click on the Help option in the menu bar and select Install New Software. Then, let’s add the link to the Oracle Enterprise Pack to install the GlassFish Tool:
首先,让我们点击菜单栏中的帮助选项,然后选择安装新软件。然后,让我们添加 Oracle Enterprise Pack 的链接,以安装 GlassFish 工具:
more
安装 GlassFish 工具。
Here, we add the link to Oracle Enterprise Pack and press the Enter key. All the available software is loaded, but our interest is in the GlassFish tool. Hence, we select the GlassFish tool and click the Next button to install the tool.
在这里,我们添加 Oracle Enterprise Pack 的链接,然后按下 Enter 键。所有可用软件都已加载,但我们感兴趣的是 GlassFish 工具。因此,我们选择 GlassFish 工具,并单击 Next 按钮安装该工具。
After installation, let’s restart the Eclipse IDE and check the GlassFish tool. First, let’s click on the Windows option in the menu bar. Next, let’s click on the Show View option. Finally, let’s choose the Servers option:
安装完成后,让我们重启 Eclipse IDE 并检查 GlassFish 工具。首先,让我们点击菜单栏中的 Windows 选项。接着,点击 Show View 选项。最后,让我们选择 Servers 选项:
We now have Servers in our view. Let’s click on the link “Create New Server” to see the GlassFish Tool:
现在,我们的视图中有了服务器。让我们点击链接”创建新服务器”查看 GlassFish 工具:
Notably, the current GlassFish tool in Eclipse IDE for Enterprise Java Developer supports only GlashFish versions 1, 3, and 5.
值得注意的是,Eclipse IDE for Enterprise Java Developer 中的当前 GlassFish 工具仅支持 GlashFish 1、3 和 5 版本。
2.2. Setting up GlassFish Server
2.2.设置 GlassFish 服务器
Furthermore, let’s download GlassFish 5.1 and extract it to a folder. Notably, GlassFish 5.1 provides support for only Java 8.
此外,让我们下载 GlassFish 5.1 并将其解压缩到一个文件夹中。值得注意的是,GlassFish 5.1 仅支持 Java 8。
Next, let’s click on Create a new server in the Servers view. This opens the server tools, and let’s select GlassFish:
接下来,让我们点击 Servers 视图中的 Create a new server(创建新服务器)。这将打开服务器工具,让我们选择 GlassFish:.
Here, we click on Create a new server and select GlassFish. Additionally, we click on the Add option to create the GlassFish runtime environment by specifying the path to the extracted GlassFish server.
在这里,我们单击 Create a new server(创建新服务器) 并选择 GlassFish。此外,我们点击 Add 选项,通过指定提取的 GlassFish 服务器的路径来创建 GlassFish 运行时环境。
Alternatively, we can right-click in the Servers view and select the “New” option to add a new server.
或者,我们可以在服务器视图中单击右键,然后选择”新建“选项来添加新服务器。
After clicking the Add option, let’s specify the path to the server and JDK:
单击添加选项后,让我们指定服务器和 JDK 的路径:
In the above image, we define the path to the GlassFish server and the JDK. Finally, we click on the Finish button to add the GlassFish runtime properties.
在上图中,我们定义了 GlassFish 服务器和 JDK 的路径。最后,我们单击 Finish 按钮添加 GlassFish 运行时属性。
Next, let’s go back to the New Server view and select the GlassFish server runtime we just created:
接下来,让我们回到 New Server 视图,选择刚刚创建的 GlassFish 服务器运行时:
The Next button takes us to a page to define the server properties like the Admin password:
下一步按钮将带我们进入一个页面来定义服务器属性,如管理员密码: Admin password: <a href=”/wp-content/uploads/2023/10/define_glassfish_property.
For simplicity, we didn’t define the admin username and password.
为简单起见,我们没有定义管理员用户名和密码。
The Next button takes us to a page to add resources to the server:
Our goal is to set up a server, so we leave the configured box empty and click Finish.
我们的目标是建立一个服务器,因此我们将配置框留空,然后单击完成。
The server is now fully set up and can be assessed from the Servers view:
服务器现已完全设置完毕,可从 Servers 视图中进行评估: 服务器视图。
The server is now listed in the Servers view. Next, let’s select it and click on the start button to start the server.
现在,服务器已在 Servers 视图中列出。接下来,让我们选中它并单击启动按钮来启动服务器。
Finally, let’s open the URL “http://localhost:8080” in our browser to see the running server:
最后,让我们在浏览器中打开 URL”http://localhost:8080“,查看正在运行的服务器: <a href=”/wp-content/uploads/2023/10/index_page_of_glassfish_server.
The above image shows the index page of the running server.
上图显示的是正在运行的服务器的索引页面。
3. Conclusion
3.结论
In this article, we learned how to setup a GlassFish server within the Eclipse IDE through a step-by-step guide.
在本文中,我们通过逐步指导学习了如何在 Eclipse IDE 中设置 GlassFish 服务器。
Additionally, we saw how to install the Eclipse GlassFish tools via the Oracle Enterprise Pack.
此外,我们还了解了如何通过 Oracle Enterprise Pack 安装 Eclipse GlassFish 工具。