DevStuffz
DevStuffz

Reputation: 39

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

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

Upvotes: 0

Views: 1133

Answers (2)

user13510609
user13510609

Reputation:

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

Upvotes: 0

NoDataFound
NoDataFound

Reputation: 11979

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).

Upvotes: 2

Related Questions