Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Javac command  RSS feed

 
Michael Houston
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know this is probably the dumbest of dumb questions, but I am completely new to both Java and programming in general.

When I attempt to compile a simple program using the javac command, I am receiving an error:

javac: file not found: I have set my path system variable to the javac bin folder filepath (C:\Program Files\Java\jdk1.8.0_71\bin), but this doesn't seem to make any difference. Does anyone have any advice?
 
Knute Snortum
Sheriff
Posts: 4073
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, let's see if javac is in the PATH. Try:

javac -version

If this comes back okay, maybe it can't find the file to compile. Could you post the entire command and error message?
 
Stephan van Hulst
Saloon Keeper
Posts: 7803
142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you restart the command prompt after added the environment variable?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12542
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
confirm it is really in your path. type

echo %path%

if it's not there, see Stephan's post. the cmd window does not dynamically re-load the PATH when it's changed. It loads it when the window first opens, so changes don't get picked up. the easiest way to get it loaded it to open a new window (and close the old one so you don't get confused).

if is is in your path, then you should be able to do this:

dir "\Program Files\Java\jdk1.8.0_71\bin\javac.exe"

and have it return something like

Volume in drive C has no label.
Volume Serial Number is AA13-5086

Directory of C:\Program Files (x86)\Java\jdk1.7.0\bin

01/31/2013 11:49 AM 14,728 javac.exe
1 File(s) 14,728 bytes
0 Dir(s) 429,430,677,504 bytes free


if you get "file not found", then you have a different issue


 
Campbell Ritchie
Marshal
Posts: 55680
161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
…and welcome to the Ranch
 
Michael Houston
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"First, let's see if javac is in the PATH. Try:

javac -version "

Yes, it comes back with the version.

"Did you restart the command prompt after added the environment variable?"
Yes.

"If is is in your path, then you should be able to do this:

dir "\Program Files\Java\jdk1.8.0_71\bin\javac.exe"

When I type that, I get: The system cannot find the path specified.

"…and welcome to the Ranch "

Thanks!
 
Knute Snortum
Sheriff
Posts: 4073
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you post the command you are issuing? Does your Java file use a package statement? If so, what is it?
 
Knute Snortum
Sheriff
Posts: 4073
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is Example.java in C:\Users\Glen?
 
Michael Houston
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No...that'll be the problem then, wont it?
 
Knute Snortum
Sheriff
Posts: 4073
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Indeed.
 
Chethan Kemparaju
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael, Even I am having the same issue as yours in command prompt. Please let me know, if you have found an answer.

And fred, I tried everything you have listed. I am receiving "file not found" error!
 
Dave Tolls
Rancher
Posts: 2911
35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What directory are you in?
What command are you running?

They are the two basic questions for this issue.
 
khadar valli
Greenhorn
Posts: 26
Java MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi michael,

In the command prompt, change the directory to where your java file is exist by using "cd" command and then apply "javac" as

javac Example.java
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!