0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

EclipseでJava開発環境作成 for Windows

Posted at

概要

WindowsでJAVA,JSP,Servlet開発環境を作ったメモ。
・Windows10
・Eclipse:Pleiades All in One Eclipse 2021

セットアップ

Pleiades All in One EclipseはJDKとTOMCATが一式セットされているので
個々のインストールは不要。
ダウンロードして配置するだけです。

1.以下サイトから本体ファイルをダウンロード

image.png

2.任意の場所に展開・保存 ※下記例はEドライブ直下
_ image.png

おわり

起動

1.eclipse.exeを押下する ※Eドライブの例だと「E:\pleiades\eclipse」配下
_ image.png

2.ワークスペースの選択画面が表示される。
 起動をクリック。※フォルダ変更してもよいが規定値のままで構わない。

image.png

・起動画面
image.png

JAVAサンプル作成

1.ファイル>新規>Javaプロジェクトをクリック
image.png

2.プロジェクト名を入力し完了をクリック
image.png

作成したプロジェクトが表示される
image.png

3.パッケージを右クリック>新規>クラスをクリック
image.png

4.クラスの設定
 ・名前を入力する
 ・public static void mainをチェックする
 ・完了をクリック
image.png

>作成後。作成したクラスが表示される。
image.png

5.テスト用に、プリント関数「System.out.println("Hello World!");」を記載する
image.png

6.Ctr + zをクリックして保存。
7.実行をクリック
image.png

Servletサンプル作成

1.ファイル→新規→動的Webプロジェクトをクリック
image.png

2.プロジェクト名(ここでは「HelloServlet」とする)を入力し、完了をクリック
image.png

3.作成したパッケージ(ここではHelloServlet)を右クリック>新規>その他をクリック
image.png

4.Javaパッケージ名とクラス名を入力して、次へクリック
image.png

5.次へクリック
image.png

6.完了クリック
image.png

※完了後の画面。作成したソースが開かれ基本構文が入力済み。
image.png

7.ソース記載、保存する

package helloServlet01;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class HelloServletWorld
 */
public class HelloServletWorld extends HttpServlet {
private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public HelloServletWorld() {
        super();
        // TODO Auto-generated constructor stub
    }

/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
 */
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub

    PrintWriter out = response.getWriter();
    out.println("<html>");
    out.println("<head>");
    out.println("<title>Hello World!</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h1>Hello World!</h1>");
    out.println("</body>");
    out.println("</html>");
    out.close();

}

/**
 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
 */
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}

}

8.実行クリック
image.png

9.サーバ種類を選択。※パッケージ作成時のランタイムを選択。
image.png

10.ブラウザが起動、表示される
image.png

履歴

2021/10/29 作成

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?