简体   繁体   中英

IntelliJ IDEA can't run application with JDK

When I run my web application with Tomcat, I get an error as follow:

Caused by: Unable to find a javac compiler;

com.sun.tools.javac.Main is not on the classpath.

Perhaps JAVA_HOME does not point to the JDK.

It is currently set to "D:\\jdk1.7.0_60\\jre"

I set JAVA_HOME in Configuration, but unfortunately no effect.

在此处输入图片说明


SDKs setting in Project Structure:

在此处输入图片说明

========================================================

Problem has been solved! Application get exception when doing Ant javac task, set the "fork" property true then it find extJavac .

Appreciate @Michael Hobbs and @Dimitri Hautot.

JRE means "Java Runtime Environment". There is no javac compiler in it.

The JRE is actually a subfolder of the JDK ( Java Development Kit , where the compiler is).

Make sure your paths are correctly set in IntelliJ settings, and refer to the JDK, not the JRE.

EDIT: looking at the proposed path, all starting with "D:\\jdk1.7.0_60\\jre", maybe you installed a JRE on your computer, instead of a JDK. This might be the cause of the problem.

Project Structure -> SDK does not effect JAVA_HOME. This must be set in the OS. I'm surprised IntelliJ, ran with a JAVA_HOME issues. Should be something alone the lines of:

Linux shell export JAVA_HOME=/home/michael/jdk1.7.0_65

Windows How to set java_home on Windows 7?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM