8.

Eclipse でよくあるエラー一覧と対処法 — JVM / ワークスペース / ビルドパス

編集
この記事の要点
  • ワークスペースを開くことができません はロックファイル .metadata/.lock の残骸が原因。Eclipse プロセス終了後に削除
  • Could not create the Java Virtual Machineeclipse.ini-Xmx 過大か JDK パス不正
  • The selection cannot be launched は実行構成 (Run Configuration) が壊れている or main 未検出
  • Resource is out of sync はファイルがエディタ外で変更された状態。F5 でリフレッシュ
  • Tomcat 連携の Server timeoutサーバープロパティ → Timeouts を 45 秒 → 120 秒程度に延長

Eclipse でよくあるエラー一覧

Eclipse は機能が豊富な反面、初学者がつまずきやすいエラーが多数あります。代表的なものを症状・原因・対処の三段で整理します。

1. ワークスペースを開くことができません

Could not launch the product because the associated workspace
is currently in use by another Eclipse application.

Workspace in use or cannot be created, choose a different one.

原因: 別 Eclipse がそのワークスペースを開いている、または前回異常終了で .lock ファイルが残っている。

対処:

  1. タスクマネージャで eclipse.exe / javaw.exe を全終了
  2. ワークスペース直下の .metadata/.lock を削除
  3. 必要なら .metadata/.plugins/org.eclipse.core.resources/.snap も削除
  4. Eclipse を再起動

2. Could not create the Java Virtual Machine

Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap

または

A JRE or JDK must be available in order to run Eclipse.
No Java virtual machine was found

原因:

  • eclipse.ini-Xmx が物理メモリより大きい
  • JDK / JRE のパスが間違っている
  • 32bit Eclipse に 64bit JDK / 64bit Eclipse に 32bit JDK
# eclipse.ini の修正例
-vm
C:\Program Files\Eclipse Adoptium\jdk-21\bin\javaw.exe
-vmargs
-Xms512m
-Xmx2048m      ← 物理メモリの 1/4 程度まで
-XX:+UseG1GC

注意: -vm-vmargs より前に書く必要があります。

3. プロジェクトのビルドパス未設定 / The project cannot be built until build path errors are resolved

The project was not built since its build path is incomplete.
Cannot find the class file for java.lang.Object.
Fix the build path then try building this project

対処:

  1. プロジェクト右クリック → PropertiesJava Build Path
  2. Libraries タブを開き JRE System Library が正しい JDK を指しているか確認
  3. 不要なエラー Library を削除し Add Library → JRE System Library で再追加
  4. Order and Export タブで JRE が必要な位置に
  5. Project → Clean で再ビルド

4. The selection cannot be launched, and there are no recent launches

原因: main メソッドが無いクラスを実行しようとした、もしくは Run Configuration が壊れている。

対処:

  • クラスに public static void main(String[] args) があるか確認
  • Run → Run Configurations → 該当を選び Main class を再入力
  • あるいは右クリック Run As → Java Application から再生成

5. Resource is out of sync with the file system

原因: Eclipse 外でファイルが変更された (Git pull、エディタ外編集など)。

対処:

  • プロジェクト選択 → F5 (リフレッシュ)
  • または Window → Preferences → General → WorkspaceRefresh using native hooks or polling をチェック (自動リフレッシュ)

6. コンパイラ準拠レベル不一致

The type java.lang.String cannot be resolved.
It is indirectly referenced from required .class files

または

Lambda expressions are allowed only at source level 1.8 or above

対処:

  1. プロジェクト → Properties → Java Compiler
  2. Compiler compliance level をプロジェクトの Java バージョンに合わせる (例: 17, 21)
  3. Project Facets でも Java バージョンを揃える
  4. pom.xmlmaven.compiler.source/target も整合させる

7. Tomcat: Server timeout / Server did not start within X seconds

Server Tomcat v9.0 Server at localhost was unable to start within 45 seconds.
If the server requires more time, try increasing the timeout in the server editor.

対処:

  1. Servers ビューで Tomcat をダブルクリック
  2. Timeouts セクションを開く
  3. Start を 120 秒、Stop を 60 秒に変更
  4. 保存 (Ctrl+S) → サーバー再起動

別の Server timeout 原因:

  • Tomcat のポート (8080) が既に使われている → netstat -ano | findstr 8080
  • JVM オプション -Xmx 不足 → Servers ビューで Server を開き Open launch configuration から増やす
  • 起動時のスクリプトで Spring の Bean 初期化に時間がかかっている → ログを確認

8. Workspace in use (ロックファイル)

対処: 上述の .metadata/.lock 削除 + プロセスキル。

9. プラグインインストール失敗

An error occurred while collecting items to be installed
session context was:(profile=epp.package.jee, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect)
Failed to read repository...

対処:

  • プロキシ設定: Preferences → General → Network Connections → Manual でプロキシ入力
  • SSL 証明書エラー: 社内環境の場合は CA 証明書を cacerts に追加
  • キャッシュ削除: .eclipse/p2 を削除して再試行

10. その他よくあるエラー早見表

メッセージ対処
An internal error occurred during: "Building workspace"Project → Clean → 全プロジェクト再ビルド
Errors occurred during the build. Errors running builder 'JavaScript Validator'Properties → Builders で JS Validator を OFF
Editor does not contain a main typemain メソッドが含まれるクラスを開いてから実行
Could not write metadata for ...権限不足。Eclipse を管理者で実行 or ワークスペースを別ドライブへ
Plug-in ... was unable to load classHelp → About → Installation Details で該当プラグインを削除→再インストール

FAQ

Q: エラーが出たらまず何をすればよい?
A: ① Project → Clean → 全プロジェクトF5 でリフレッシュEclipse 再起動ワークスペース新規作成.metadata 削除。下に行くほど破壊的なので順番に試します。

Q: Eclipse が重い・遅い
A: eclipse.ini-Xmx を増やす、不要プラグインを削除、Validators を OFF、JDK は Adoptium Temurin 推奨。

Q: IntelliJ IDEA と比べてどう?
A: 業務 Java 開発では IntelliJ の方が補完・リファクタが優秀ですが、Eclipse は無料で実績豊富。チームの慣れで選びましょう。

編集
Post Share
子ページ
  1. モジュール名が無効です。(WAR エクスポート)
  2. 現在のブランチはプル用に構成されていません 構成にキー remote.origin.url の値がありません
  3. サーバーに追加または除去できるリソースがありません。
  4. invalid LOC header (bad signature)
同階層のページ
  1. Pleades導入方法(Windows)
  2. Tomcatの起動ボタンを表示
  3. 色・テーマの変更
  4. Tomcatプロジェクトのディレクトリ構成
  5. プロジェクトをTomcatプロジェクトとして認識させる方法
  6. Webアプリケーションのデプロイ方法
  7. 便利ショートカット一覧
  8. エラー一覧
  9. サーバーの設定
  10. サーバーとプロジェクトの紐づけ
  11. Tomcatの起動時のログがconsole上に表示されない時の対応
  12. macOSで複数のワークスペースを起動させる方法