• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Environment variables

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I could really use some help if someone knows how to do this. I have installed jdk1.6.0 on my laptop. The path is set to: C:\Program Files\Java\jdk1.60\bin\;. I also have the ClassPath set to the same setting. When I try to compile a program I get the following error:
"javac: filenot found:program name.java
usage: javac<options><sourcefiles>
use -help for a list of possible options.
Thanks.
Tom.




[edit]Disable smilies. CR[/edit]
[ July 17, 2008: Message edited by: Campbell Ritchie ]
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

"javac: filenot found rogram name.java
usage: javac<options><sourcefiles>
use -help for a list of possible options.



seems like you are trying to compile the .java file "name", in wrong directory ! Where you saved that file (name.java) , Go to that directory and run this command :

<blockquote>code:
<pre name="code" class="core">javac name.java [ENTER]</pre>
</blockquote>

try this,
 
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, and welcome to the ranch,

As Sagar points out, the "file not found" message tells us that the problem is that the compiler (i.e. javac) is not finding your java file. But first. there is some house keeping to do with your CLASSPATH environment variable. Remove the "C:\Program Files\Java\jdk1.60\bin\" from your CLASSPATH environment variable. (And change the name of it to all upper case if it is not). You don't need (or want) the java bin directory in your classpath. Keep the "C:\Program Files\Java\jdk1.60\bin\" in your PATH. Set your CLASSPATH environment variable to "." (Just a period without the quotes.) The period means the current directory. While not explicitly needed, it is often very helpful, especially when one class you are compiling is dependent on another class in the same directory.

To compile your file...
Let's say the java file 'MyJavaClass.java' is located at "C:\projects\src\MyJavaClass.java". And I want to compile it. We need to change directory to the same directory as the java file (assuming your class is not in a package)and then compile it:
<blockquote>code:
<pre name="code" class="core">
C:\> cd \projects\src
C:\projects\src> javac MyJavaClass.java
</pre>
</blockquote>

Alternatively, if you don't want to change directory to the directory that has your java file in it, you can specify the full path to where your file is:
<blockquote>code:
<pre name="code" class="core">
C:\> javac C:\projects\src\MyJavaClass.java
</pre>
</blockquote>

If you have other class in that directory that MyJavaClass depends on, you need to have that i your classpath; this can be done at the command line:
<blockquote>code:
<pre name="code" class="core">
C:\> javac -classpath "C:\projects\src\" C:\projects\src\MyJavaClass.java
</pre>
</blockquote>

Give that a try. If you are still having problems, let us know.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do not set the CLASSPATH to the bin directory of your JDK installation. CLASSPATH is used by Java to search for Java class files, and there are no Java class files in the bin directory of your JDK.

On Java 5 and newer, it's best to leave CLASSPATH unset (don't define a CLASSPATH environment variable). If you do that, Java will automatically look in the current directory for class files.
 
Thomas Cook
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Guys this worked. You guys are life savers.
Tom.
reply
    Bookmark Topic Watch Topic
  • New Topic