简体   繁体   中英

Javac Not found after setting the path

I was messing around with writing Java code without an ide, and compiling/running with command prompt. When I try to create the.class, I get an error saying that Javac is not recognized. I was looking for answers when I found this thread https://stackoverflow.com/questions/1299750/javac-not-recognized But nothing was working. I have done the following

  • Set C:\Program Files\Java\jre1.8.0_51\bin as a path
  • Set the path in the command line
  • Reinstalled the jdk

It also should be noted that If I had the.class then java Main.class will work

From the path you are using ( C:\Program Files\Java\jre1.8.0_51\bin ), it most likely is a JRE.

javac is part of the JDK.

Also, you should use a recent version of Java 8.

  • Oracle Java 8u202 (last version before the licence change)
  • Adopt OpenJDK (the link point to the JDK 8).

C:\Program Files\Java\jre1.8.0_51\bin is the path to the JRE (Java Runtime Environment) - normally installed together with the JDK; or as standalone (without JDK);
try C:\Program Files\Java\jdk1.8.0_51\bin , assuming the JDK (Java Development Kit) was installed there. Anyway it must be the directory where javac.exe is located.

Note: the last sentence is probably not correct:
java Main.class will try to start the class Main.class found in file Main.class.class .
Probably, to start the Main class it should be java Main

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