0

I have installed the JRE (jre1.8.0_181) and the JDK (jdk1.8.0_111) on Windows 7.

I checked that the environment variables are well defined :

C:\Users\denis.beurive>echo %JAVA_HOME%
C:\Progra~1\Java\jdk1.8.0_111

C:\Users\denis.beurive>echo %CLASSPATH%
C:\Progra~1\Java\jdk1.8.0_111\lib

C:\Users\denis.beurive>echo %PATH%
...C:\Progra~1\Java\jdk1.8.0_111\bin;C:\Progra~2\Java\jre1.8.0_181\bin;...

And I made sure that the directories exist :

dir %JAVA_HOME%
dir %CLASSPATH%
dir C:\Progra~2\Java\jre1.8.0_181\bin
dir C:\Progra~1\Java\jdk1.8.0_111\bin

The directories exist.

Please note that I followed the recommendation that I found here, regarding the paths: JAVA_HOME variable

However, when a run the java compiler, I get an error :

C:\Users\denis.beurive>javac
Erreur : impossible de trouver ou charger la classe principale com.sun.tools.javac.Main
C:\Users\denis.beurive>javac -help
Erreur : impossible de trouver ou charger la classe principale com.sun.tools.javac.Main

I am stuck. I found many posts about "com.sun.tools.javac.Main" not found. However, I think that it does not apply to my specific situation, since the compiler crashes even without compiling anything.

Any Idea ?

PS: The JRE works fine (Tomcat runs...)

Note : there is no "pack" file in the directory "lib":

C:\Users\denis.beurive>dir C:\Progra~1\Java\jdk1.8.0_111\lib
 Le volume dans le lecteur C n'a pas de nom.
 Le numéro de série du volume est 3C7D-8A4C

 Répertoire de C:\Progra~1\Java\jdk1.8.0_111\lib

20/09/2018  08:30    <REP>          .
20/09/2018  08:30    <REP>          ..
19/10/2016  13:41         1 895 938 ant-javafx.jar
19/10/2016  13:41        17 403 201 ct.sym
19/10/2016  13:41           163 047 dt.jar
19/10/2016  13:41            18 432 ir.idl
19/10/2016  13:41            36 038 javafx-mx.jar
19/10/2016  13:41             1 682 jawt.lib
19/10/2016  13:41           407 728 jconsole.jar
19/10/2016  13:41           741 084 jvm.lib
19/10/2016  13:41    <REP>          missioncontrol
19/10/2016  13:41               640 orb.idl
19/10/2016  13:41             4 646 packager.jar
19/10/2016  13:41         2 419 817 sa-jdi.jar
19/10/2016  13:41    <REP>          visualvm
              11 fichier(s)       23 092 253 octets
               4 Rép(s)  15 330 598 912 octets libres
Denis Beurive
  • 305
  • 2
  • 10
  • Did you close and reopen command prompt after setting the JAVA HOME variable? – dustytrash Sep 21 '18 at 14:13
  • Yes. I close the command prompt each time I modify the environment. – Denis Beurive Sep 21 '18 at 14:19
  • Seems like you miss tools.jar: I have `20.01.2018 11:07 18 248 552 tools.jar` while you don't. The message you get corresponds to this suspicion. I'd suggest to reinstall the JDK. – m. vokhm Sep 21 '18 at 14:23
  • @dustytrash The TS does not have it in the `lib/` – m. vokhm Sep 21 '18 at 14:27
  • I found the problem ! I did not notice, but I have 2 JDK installed (`1.8.0_111` and `1.8.0_181`) ! And for some reason, the system was configured for the version `1.8.0_111`! (which does not have the file `tools.jar`) I set `JAVA_HOME` and `CLASSPASS` relatively to the installation directory for the version `1.8.0_181`, and it solved the problem. – Denis Beurive Sep 21 '18 at 14:54

0 Answers0