• Post Reply Bookmark Topic Watch Topic
  • New Topic

Javac  RSS feed

 
Hillary Blank
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having trouble with 'javac' in the command line (I'm an extreme beginner):

I have JDK installed, and I restarted my computer.

I added C:\Program Files (x86)\Java\jdk1.7.0_60\bin to my environmental variables (*note, there are other environmental variables already set in the path; I just added the jdk variable to the mix).

I have helloJava.java saved in c:\Users\Hillary\Code

When I run c:\Users\Hillary\Code>javac helloJava.java in the command line, I get the error 'javac: file not found: helloJava.java.' (I have double checked to make sure helloJava is in the directory, so that is not the problem.)

Is there something I am missing? Thanks in advance for the help!
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Hillary Blank wrote:When I run c:\Users\Hillary\Code>javac helloJava.java in the command line, I get the error 'javac: file not found: helloJava.java.' (I have double checked to make sure helloJava is in the directory, so that is not the problem.)

You say you have double checked it, but still the Java compiler is telling you that it cannot find the file.

Try the 'dir' command. Do you see a file named 'helloJava.java' in your directory? Maybe it is really called 'helloJava.java.txt' (that happens when you create the file with Notepad)? Then rename it so that it doesn't have the '.txt' extension.
 
Paweł Baczyński
Bartender
Posts: 2087
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Can you execute dir command and put result here?
Double-check if your file is named exactly helloJava.java and not helloJava.java.txt (Windows Notepad could save it like that).

59 seconds late
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paweł Baczyński wrote:
59 seconds late


The fact that the two responses were almost identical just proves how common it happens.

Henry
 
Hillary Blank
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much!

The directory was listing helloJava (without the .java). Turns out the text editor I was using (Sublime Text 2) was saved in Program Files rather than Program Files (86) where my JDK is saved - I'm on Windows 8. I moved the text editor to Program Files (86), resaved my program, and the directory is now listing helloJava.java. Everything seems to be working now. Thanks for helping me with my first program!
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome again. I presume you added that path at the beginning of your system PATH?
If you can find the file as you expect to find it, try this instruction:-
echo %CLASSPATH%
Show us what it returns. It ought to return nothing. If you find the file with .txt appended, try a different editor. If I ever use Windows® I usually use NotePad++.
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see you sorted it out before I managed to post. Well done
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!