• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Javac command

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 7123
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Saloon Keeper
Posts: 14503
325
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you restart the command prompt after added the environment variable?
 
lowercase baba
Posts: 13082
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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


 
Marshal
Posts: 76884
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
…and welcome to the Ranch
 
Michael Houston
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 7123
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 7123
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is Example.java in C:\Users\Glen?
 
Michael Houston
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No...that'll be the problem then, wont it?
 
Knute Snortum
Sheriff
Posts: 7123
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Indeed.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What directory are you in?
What command are you running?

They are the two basic questions for this issue.
 
Greenhorn
Posts: 26
MySQL Database Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic