33

I am getting Cannot get the System Java Compiler. Please use a JDK, not a JRE. when jsp file are in the my project and I deploy my it to Google App Engine. So I tried the following to fix the problem:

  1. Add -vm C:\Program Files\Java\jdk1.6.0_43\bin\javaw.exe to my eclipse.ini.
  2. Ensure that the JDK is in my project's build path and not the jre.
  3. Add the C:\Program Files\Java\jdk1.6.0_43\bin\ to the PATH for Environment Variable.

But none of these solved the problem. How can I solve this?

user2054833
  • 2,115
  • 7
  • 24
  • 39

14 Answers14

35

When adding -vm C:\Program Files\Java\jdk1.6.0_43\bin\javaw.exe to eclipse.ini, make sure to put -vm and C:\Program Files\Java\jdk1.6.0_43\bin\javaw.exe on separate lines

FDinoff
  • 30,689
  • 5
  • 75
  • 96
user2403826
  • 351
  • 2
  • 2
  • I also have to add that my Eclipse went crazy. I have donde this, but it did not work. Then I installed a new Eclipse, and it went wrong again. Then I installed a new Eclipse again, and point the workspace to some other folder, and this solution worked! Just a tip in case someone has the same strange behaviour. – InsaurraldeAP Aug 21 '13 at 21:28
30

Following 2 things worked for me.

1)Make sure your JAVA_HOME path is set to JDK and JAVA_HOME is included in PATH.

2) Add first two lines of following code in eclipse.ini . It should look like below.

-vm
C:\Program Files\Java\jdk1.7.0_03\bin\javaw.exe
-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.200.v20130807-1835-product
org.eclipse.epp.package.standard.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.6
-Xms40m
-Xmx512m
Harshit
  • 692
  • 10
  • 17
15

Could you paste your eclipse.ini file here? I just added the vm line some days ago, and it worked fine.

Just remember it has to be put BEFORE the -vmargs line...

Lord Khizir
  • 304
  • 1
  • 7
5

I had the same problem and reached a conclusion:

If the Eclipse is executed with JRE, it will use JRE instead of JDK when deploying to App Engine even if Preference setting is set to use JDK.

Solution: change JAVA_HOME path to JDK from JRE and make sure JAVA_HOME\bin is included in PATH. Then, restart Eclipse.

seongjoo
  • 471
  • 5
  • 16
4

I solve this problem by editting the appcfg.cmd file under the Google App Engine SDK folder.

The appcfg.cmd file is located at

{eclipse directory}\plugins\com.google.appengine.eclipse.sdkbundle_1.8.8\appengine-java-sdk-1.8.8\bin

Change the java string in the command to the specific location of java.exe under jdk folder:

Original:

java -Xmx1100m -cp "%~dp0..\lib\appengine-tools-api.jar" com.google.appengine.tools.admin.AppCfg %*

After changing:

"C:\Program Files\Java\jdk1.7.0_45\bin\java.exe" -Xmx1100m -cp "%~dp0..\lib\appengine-tools-api.jar" com.google.appengine.tools.admin.AppCfg %*

IntoCode
  • 57
  • 1
  • 6
3

I encountered the same error ["cannot get the system java compiler"] while uploading the sample war guestbook. I had JDK installed and "java -version" could print version information correctly. So which part has gone wrong?
The cause of the problem lies here:

Other than the %JAVA_HOME%/bin directory, java.exe/javaw.exe also exist in C:\Windows\ sub-directory.

The uploading command used the java.exe in c:\windows\ sub-directory instead of that resides in the %JAVA_HOME% directory.
Solution:
Put "%JAVA_HOME%/bin" at the head of the PATH environment variable definition. This should guarantee that the %JAVA_HOME% stuff be used.

Damodaran
  • 10,882
  • 10
  • 60
  • 81
user3016498
  • 41
  • 1
  • 4
  • this also works, not sure what's the correct way of handling this issue... this or editing the eclipse.ini file? – xtrahelp.com Sep 07 '16 at 04:37
  • Putting it at the start of the PATH environment is essential. No change to the eclipse.ini was needed for me. – Andrew-NZ Mar 18 '17 at 20:18
2
  1. Edit eclipse ini and add -vm C:\Program Files\Java\jdk1.7.0_65\bin\javaw.exe as follow (between these lines):

    --launcher.defaultAction openFile -vm C:\Program Files\Java\jdk1.7.0_65\bin\javaw.exe --launcher.appendVmargs

  2. Set up your JAVA_HOME to point to jdk folder (C:\Program Files\Java\jdk1.7.0_65)

It worked perfectly for me.

jsaf
  • 59
  • 4
1

The last resort: an easy but admittedly not very elegant solution is to uninstall all JREs.

rwitzel
  • 1,694
  • 17
  • 21
  • I tried many different solutions but eventually fell to this. It was the only answer that worked. I simply moved the "jre7" directory elsewhere (so I could restore it if need be). – Brian White Nov 09 '13 at 02:10
  • The unistall did not work for me. I used the eclipse.ini tweak and installed the JRE in libraries. Although there is a red cross in the Project Explorer guestbook.jsp, it runs like devil both local and remote. The google guys are crazy.. – Timo Feb 13 '14 at 20:31
0

Go to Windows -> Preferences -> Java -> Installed JREs -> Add... and then set the path to your JDK folder as JRE home. The remaining fields will be filled-in automatically. Then, in the list Installed JREs make sure the newly added JDK is marked as the default one.

gcvt
  • 1,482
  • 13
  • 15
0

Make sure that your JAVA_HOME environment variable refers to the JDK home directory, not JRE.

gluckonavt
  • 236
  • 1
  • 4
0

Strange enough, I was confronted with this issue suddenly without any changes (apart maybe from a upgrade from windows 8 to windowns 8.1).

I was able to solve it by putting -vm before -vmargs in the eclipse.ini file.

Slaine
  • 31
  • 2
0

I did everything everyone else said and nothing worked. I had to change the type of project: Project -> Properties-> Project Facets and check Dynamic Web Module. After that I was able to deploy the project.

0

I have received this error in Android Studio when building the project. I have set JDK location in the settings (File ==> Settings) and it solved the issue for me.

0

I updated all of the suggested spots to point to my jdk1.8.0_111 rather than jre: Eclipse.ini, system path, JAVA_HOME. Also removed the Oracle entry from my path: C:\ProgramData\Oracle\Java\javapath (which pointed at the jre). In the end I found one more spot that referenced the jre, which finally fixed it:

In Eclipse -> my project Properties -> Java Build Path -> JRE System Library was still pointed at my jre. Removed it, did "Add Library" and pointed it at my jdk. Restarted Eclipse and I could finally deploy with a jsp.

I went back and removed JAVA_HOME and it still works (JAVA_HOME interferes with other build systems).

Looking forward to figuring out a good command line build so I don't have random compilers being used.

Eric McNeill
  • 1,784
  • 1
  • 18
  • 29