Как подключить java ee в idea
Перейти к содержимому

Как подключить java ee в idea

  • автор:

Подключение SQLite в IntelliJ IDEA

JSP и Intellij Idea
Добрый вечер, не могу разобраться с одной "проблемой" уже 4 часа. Не могу запустить даже.

‘?’ expected, got ‘:’ + Intellij Idea
Что это за ошибка ? Как ее исправить ?

Как подключиться к БД в IntelliJ IDEA 9.0?
Всем доброго времени суток. у меня такой вопрос как подключаться к БД? пароль и логин хранится в.

Эксперт Java

3638 / 2970 / 918
Регистрация: 05.07.2013
Сообщений: 14,220

ЦитатаСообщение от Murloc_Knight Посмотреть сообщение

Class.forName(«org.sqlite.JDBC»);
это вообще не надо делать, само должно работать

Эксперт Java

2486 / 1038 / 355
Регистрация: 11.08.2017
Сообщений: 3,186

Использовать мавен и не будет проблем, проверьте наличие библиотеки в classpath
драйвер можно и так зарегистрировать DriverManager.registerDriver(new JDBC()); хотя это выполняется в статик блоке класса DriverManager и выполнится в любом случае при первом использовании класса DriverManager, что по сути тоже излишне

Регистрация: 21.06.2018
Сообщений: 50
в общем нужно было jar-ник кинуть в папку lib в папке WEB-INF
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
Помогаю со студенческими работами здесь

Intellij idea settings. JSF
Всем доброго времени суток! Я пытаюсь создать элементарную страничку JSF типа "Hello world" — не.

Настройка Tomcat6 в IntelliJ IDEA 9.0.3
Всем привет! Дорогие программисты помогите как настроит томкат6 в IntelliJ IDEA 9.0.3. Там где.

Intellij idea + Hibernate начало работы
Здравствуйте! Нашла много информации о том, как работать с Hibernate, однако не могу понять, как.

Intellij IDEA Glassfish Remote deployment
Всем привет. Подскажите как задеплоить проект(сервлет hello world) на удаленный Glassfish-сервер в.

Web application на Intellij Idea Community Edition
Кто нибудь знает как создать Web application на Intellij Idea Community Edition.

Ошибка при переходе на страницу в IntelliJ IDEA
Здравствуйте! Проблема в том, что при запуске проекта(веб-сайт) Intellij idea, главная страничка.

Tutorial: Your first Java EE application

This tutorial describes how to create a simple Java EE web application in IntelliJ IDEA. The application will include a single JSP page that shows Hello, World! and a link to a Java servlet that also shows Hello, World! .

You will create a new Java Enterprise project using the web application template, tell IntelliJ IDEA where your GlassFish server is located, then use a run configuration to build the artifact, start the server, and deploy the artifact to it.

Here is what you will need:

IntelliJ IDEA Ultimate

Java Enterprise development is not supported in the free IntelliJ IDEA Community Edition. For more information, refer to IntelliJ IDEA Ultimate vs IntelliJ IDEA Community Edition

Relevant bundled plugins

By default, all necessary plugins are bundled and enabled in IntelliJ IDEA Ultimate. If something does not work, make sure that the following plugins are enabled:

  • Jakarta EE Platform
  • Jakarta EE: Application Servers
  • Jakarta EE: Web/Servlets
  • GlassFish

For more information, refer to Install plugins.

Java SE Development Kit (JDK) version 1.8 or later

You can get the JDK directly from IntelliJ IDEA as described in Java Development Kit (JDK) or download and install it manually, for example: Oracle JDK or OpenJDK.

The GlassFish application server version 4.0 or later. You can get the latest release from the official repository. The Web Profile subset should be enough for the purposes of this tutorial.

This tutorial uses Oracle OpenJDK 17, Jakarta EE 9.1, and GlassFish 6.2.5. For more information about the compatibility between other GlassFish, Java, and Jakarta EE versions, refer to https://github.com/eclipse-ee4j/glassfish#compatibility.

You will need a web browser to view your web application.

Create a new Java Enterprise project

IntelliJ IDEA includes a dedicated wizard for creating Java Enterprise projects based on various Java EE and Jakarta EE implementations. In this tutorial, we will create a simple web application.

  1. Go to File | New | Project .
  2. In the New Project dialog, select Jakarta EE .
  3. Enter a name for your project: JavaEEHelloWorld .
  4. Select the Web application template, Maven as a build tool, and use Oracle OpenJDK 17 as the project SDK. Don’t select or add an application server, we will do it later. Click Next to continue. New Java Enterprise project wizard
  5. In the Version field, select Jakarta EE 9.1 because that’s what GlassFish 6.2.5 used in this tutorial is compatible with. For GlassFish 5, select the Java EE 8 specification. For GlassFish 7, select Jakarta EE 10. In the Dependencies list, you can see that the web application template includes only the Servlet framework under Specifications . New Java Enterprise project wizard
  6. Click Create .

Explore the default project structure

IntelliJ IDEA creates a project with some boilerplate code that you can build and deploy successfully.

    pom.xml is the Project Object Model with Maven configuration information, including dependencies and plugins necessary for building the project.

<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> JSP — Hello World Hello Servlet
package com.example.demo; import java.io.*; import javax.servlet.http.*; import javax.servlet.annotation.*; @WebServlet(value = «/hello-servlet») public class HelloServlet extends HttpServlet < private String message; public void init() < message = "Hello World!"; >public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException < response.setContentType("text/html"); // Hello PrintWriter out = response.getWriter(); out.println("«); out.println(«

» + message + «

«); out.println(««); > public void destroy() < >>

Use the Project tool window to browse and open files in your project or press Control+Shift+N and type the name of the file.

Configure GlassFish

IntelliJ IDEA can build and deploy your application’s artifacts if you specify the location of your server. For this tutorial, you should have the GlassFish server installed. You can download GlassFish from the official project website.

GlassFish application server configuration

  1. Press Control+Alt+S to open the IDE settings and then select Build, Execution, Deployment | Application Servers .
  2. Click and select Glassfish Server .
  3. Specify the path to the GlassFish server install location. IntelliJ IDEA detects and sets the name and version appropriately.

Create a GlassFish run configuration

IntelliJ IDEA needs a run configuration to build the artifact and deploy it to your application server.

  1. Go to Run | Edit Configurations .
  2. In the Run/Debug Configurations dialog, click , expand the Glassfish Server node, and select Local .
  3. Fix any warnings that appear at the bottom of the run configuration settings dialog. GlassFish run configuration warningMost likely, you will need to fix the following:
    • On the Server tab, set the Server Domain to domain1 .
    • On the Deployment tab, add the artifact that you want to deploy: JavaEEHelloWorld:war exploded
  4. On the Server tab, set the URL to http://localhost:8080/JavaEEHelloWorld-1.0-SNAPSHOT/ and save the run configuration. GlassFish run configuration done
  5. To run the configuration, press Alt+Shift+F10 and select the created GlassFish configuration.

This run configuration builds the artifact, then starts the GlassFish server, and deploys the artifact to the server. You should see the corresponding output in the Run tool window.

Started GlassFish server and deployed application in the Run tool window

Once this is done, it opens the specified URL in your web browser.

Deployed application output in the web browser

Modify the application

Whenever you change the source code of the application, you can restart the run configuration to see the changes. But this is not always necessary, especially when you can’t restart the server. Most of the changes are minor and don’t require rebuilding the artifacts, restarting the server, and so on. Let’s change the JSP page of the application.

  1. Open index.jsp and change the greeting from Hello, World! to A better greeting. .
  2. In the Run tool window, click or press Command F10 .
  3. In the Update dialog, select Update resources because the JSP page is a static resource. Click OK .
  4. Refresh the application URL in your web browser to see the new string: A better greeting.

You can configure the default update action in the run configuration settings: go to Run | Edit Configurations . Change the On ‘Update’ action option under the Server tab of the GlassFish run configuration settings.

Configure application update actions in the GlassFish run configuration

With the On frame deactivation option, you can configure to update your resources and classes without redeploying and restarting the server whenever you change focus from IntelliJ IDEA. In this case, you won’t even have to use the Update Application action, just switch to your web browser and refresh the page.

Package the application into a WAR and deploy it on a running server

In the previous steps, we deployed the application using an exploded artifact, where all files are uncompressed. This is useful during the first stages of development because it allows you to update individual resources and classes without redeploying. When you are happy with your application and ready to share it with others by deploying to a remote server, it is better to use the compressed web archive (WAR) format.

Let’s add a remote GlassFish run configuration to deploy the WAR artifact to a running server. This assumes that you did not terminate the GlassFish instance from the previous steps.

  1. Go to Run | Edit Configurations .
  2. In the Run/Debug Configurations dialog, click , expand the GlassFish Server node, and select Remote .
  3. Change the name of this run configuration to distinguish it, for example: Remote GlassFish 4.1.1 .
  4. Open the Deployment tab, click above the table of artifacts to deploy, and select Artifact . Select to deploy the JavaEEHelloWorld:war artifact and click OK . Remote GlassFish run configuration artifacts to deploy
  5. Click OK to save the remote run configuration.
  6. Open index.jsp and change the greeting to Hello from WAR! .
  7. Select the new run configuration in the main toolbar and click or press Shift+F10 . Remote GlassFish run configuration in the selector

The new configuration builds the WAR artifact and deploys it to the running server. Refresh the URL http://localhost:8080/JavaEEHelloWorld-1.0-SNAPSHOT/ and see the new greeting: Hello from WAR!

Package the application into an EAR

Proper enterprise applications are packaged into EAR files that can contain both WAR and JAR files. Let’s see how to do this in IntelliJ IDEA.

  1. In the Project tool window Alt+1 , select the top project directory.
  2. Press Control+Shift+A and type Add Framework Support . Once the action is found, click it to open the Add Framework Support dialog.
  3. In the Add Framework Support dialog, select JavaEE Application under Java EE and click OK . IntelliJ IDEA adds the META-INF/application.xml file in your module. This is the deployment descriptor for your application.
  4. Press Control+Alt+Shift+S to open the Project Structure dialog. On the Artifacts page, select the new JavaEEHelloWorld:ear exploded artifact and note that it contains only the javaEEApplication facet resource.
  5. Expand the Artifacts element under Available Elements and double-click JavaEEHelloWorld:war to add it to the EAR artifact structure. Add WAR to exploded EARWhen you see a message that says Web facet isn’t registered in application.xml , click Fix .
  6. Click , select Java EE Application: Archive , then click For ‘JavaEEHelloWorld:ear exploded’ . Add EAR artifact
  7. Select the new EAR artifact and click Create Manifest . Create manifest for EAR artifactSpecify the default location under META-INF , next to application.xml .
  8. Open application.xml . It should contain the following:

JavaEEHelloWorld.war JavaEEHelloWorldWeb

Deploy the EAR artifact

Deploying the EAR artifact is similar to deploying the WAR: you need a remote GlassFish run configuration.

  1. Go to Run | Edit Configurations .
  2. In the Run/Debug Configurations dialog, click , expand the GlassFish Server node, and select Remote .
  3. Change the name of this run configuration to distinguish it, for example: Remote EAR GlassFish 6.2.5 .
  4. Open the Deployment tab, click under the table of artifacts to deploy, and select Artifact . Select to deploy the JavaEEHelloWorld:ear artifact and click OK .
  5. Click OK to save the remote run configuration.
  6. Open index.jsp and change the greeting to Hello from EAR! .
  7. Select the new run configuration in the main toolbar and click or press Shift+F10 .

The new configuration builds the EAR artifact and deploys it to the running server. Refresh the URL http://localhost:8080/JavaEEHelloWorldWeb/ and see the new greeting: Hello from EAR! . Note that the URL corresponds to the context-root specified in application.xml .

Troubleshooting

If you get a 404 error, make sure you have selected the Jakarta EE specification version that is compatible with your version of GlassFish when creating the project.

For more information, refer to the GlassFish version compatibility.

What next?

In this tutorial, we created and deployed a simple Java enterprise application. To extend this knowledge, you can create a RESTful web service as described in Tutorial: Your first RESTful web service.

Как подключить java ee в idea

Добрый день! Подскажите, пожалуйста, в Intellij IDEA в версии Community Edition (бесплатная версия) есть Java EE? Или надо приобретать версию Ultimate? Заранее спасибо. Борис.

  • Добрый день, Борис Как ваши дела CE не поддерживает EE https www jetbrains , Аноним (1), 16:27 , 26-Май-23, (1)
    • Добрый день Евгений Спасибо за информацию Хотел по Java EE попрактиковаться, но , korbnik (??), 17:15 , 26-Май-23, (2)
      • Если совсем-совсем начинаешь изучать EE, то функционала CE должно быть достаточн, Аноним (3), 17:37 , 26-Май-23, (3)
        • Да вы задрали, преподы Почему бы не открыть тайное знание подавану — технология, ACCA (ok), 08:50 , 28-Май-23, (4)
          • Готлин, abi (?), 14:06 , 30-Май-23, (5)

          Сообщения [Сортировка по времени | RSS]

          Добрый день, Борис. Как ваши дела? CE не поддерживает EE. https://www.jetbrains.com/products/compare/?product=idea&pro. Вернее он даст только общий автокомплит и все такое, как если бы EE-код был обычным кодом, но никаких специальных EE-фич не даст. Меня кстати Евгений зовут.

          > Добрый день, Борис. Как ваши дела? CE не поддерживает EE. https://www.jetbrains.com/products/compare/?product=idea&pro.
          > Вернее он даст только общий автокомплит и все такое, как если
          > бы EE-код был обычным кодом, но никаких специальных EE-фич не даст.
          > Меня кстати Евгений зовут.

          Добрый день Евгений!

          Спасибо за информацию.

          Хотел по Java EE попрактиковаться, но не знаю пока какой IDE использовать.
          Все рекомендуют Intellij IDEA, но она платная. Есть ещё Eclipse, но он без
          internet не устанавливается. Какая то полная Ж.

          Если совсем-совсем начинаешь изучать EE, то функционала CE должно быть достаточно. Перед тем, как садиться за штурвал космического корабля, нужно освоить как минимум велосипед. А internet все-таки установи, Борис. 21 век как-никак. Даже у утюгов есть internet.

          Да вы задрали, преподы. Почему бы не открыть тайное знание подавану — технология Java выродилась в кучу дерьма. Там вообще некуда идти. Забудьте и поплачьте, давайте придумайте что-то иное. И это не ECMA-262.

          > и поплачьте, давайте придумайте что-то иное.

          Готлин

          Как установить и пользоваться технологиями Java EE?

          Используем в разработке IDEA of community edition. Как пример, используем velocity, хотя и на сайте написано, что velocity доступен только в ultimate edition. Не заморачивайтесь насчет ultimate и разбирайтесь сначала с Java SE.

          К Java standard edition относится: awt, swing, nio, math и т.д.

          К Java enterprise edition относится: EJB, JSS, JSP, JSF, JPA, JSTL и т.д.

          Java Platform, Standard Edition, сокращенно Java SE (ранее Java 2 Standard Edition или J2SE) — стандартная версия платформы Java 2, предназначенная для создания и исполнения апплетов и приложений, рассчитанных на индивидуальное пользование или на использование в масштабах малого предприятия. Не включает в себя многие возможности, предоставляемые более мощной и расширенной платформой Java 2 Enterprise Edition (J2EE), рассчитанной на создание коммерческих приложений масштаба крупных и средних предприятий.

          Java Platform, Enterprise Edition, сокращенно Java EE (до версии 5.0 — Java 2 Enterprise Edition или J2EE) — набор спецификаций и соответствующей документации для языка Java, описывающей архитектуру серверной платформы для задач средних и крупных предприятий. Спецификации детализированы настолько, чтобы обеспечить переносимость программ с одной реализации платформы на другую. Основная цель спецификаций — обеспечить масштабируемость приложений и целостность данных во время работы системы. J2EE во многом ориентирована на использование её через веб как в интернете, так и в локальных сетях. Вся спецификация создаётся и утверждается через JCP (Java Community Process) в рамках инициативы Sun Microsystems Inc. J2EE является промышленной технологией и в основном используется в высокопроизводительных проектах, в которых необходима надежность, масштабируемость, гибкость. Популярности J2EE также способствует то, что Sun предлагает бесплатный комплект разработки, SDK, позволяющий предприятиям разрабатывать свои системы, не тратя больших средств. В этот комплект входит сервер приложений с лицензией для разработки.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *