Results 1 to 11 of 11
  1. #1
    pawanmutalik is offline Member
    Join Date
    Feb 2011
    Posts
    5
    Rep Power
    0

    Unhappy need help with javac

    i have installed the jdk and set the appropriate environment variables..
    yet i m not able to run a simple program through dos
    m gettin an error saying..

    javac : File not found : hello.java
    usage : javac <options> <source files>

    please help..

  2. #2
    baloda is offline Member
    Join Date
    Nov 2010
    Location
    New Delhi
    Posts
    50
    Rep Power
    0

    Default

    u can use any ide i.e netbeans. can be downloaded from netbeans.org.

    or for testing purpose u can put ur .java file in bin directory.(C:\Program Files\Java\jdk1.6.0_22\bin). then u will not get message like this.

    but the proper way will be setting the class path accordingly.

    this type of error comes only when ur class path is not set properly.

  3. #3
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    620
    Rep Power
    4

    Default

    u can use any ide i.e netbeans. can be downloaded from netbeans.org.
    I think it is bad idea. First I advice you write all program only in text editor, for example Notepad++ and compiling and run only in command line. So you understand what you doing ).
    So about your question. Can you show content current directory where you compile code and can you show commands which you enter?
    Skype: petrarsentev
    http://TrackStudio.com

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by pawanmutalik View Post
    i have installed the jdk and set the appropriate environment variables..
    yet i m not able to run a simple program through dos
    m gettin an error saying..

    javac : File not found : hello.java
    usage : javac <options> <source files>

    please help..
    Step-down it.

    First of all make sure that all variables are set properly (actually seems that's not the issue). Just type javac and press enter. What you see?

    Are you sure that the java class file in correct place? Seems to me you've not properly set the working folder path on command prompt.

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by Petr View Post
    Can you show content current directory where you compile code and can you show commands which you enter?
    Yeah, seem that he's working on a different location.

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by baloda View Post
    u can use any ide i.e netbeans. can be downloaded from netbeans.org.

    or for testing purpose u can put ur .java file in bin directory.(C:\Program Files\Java\jdk1.6.0_22\bin). then u will not get message like this.

    but the proper way will be setting the class path accordingly.

    this type of error comes only when ur class path is not set properly.
    File Not Found, seems that the java class in a different location than from where it compile.

  7. #7
    pawanmutalik is offline Member
    Join Date
    Feb 2011
    Posts
    5
    Rep Power
    0

    Default

    the .java file that m trying to compile is in bin only..
    the program in simple program hello.java in C:\Program Files\Java\jdk1.6.0_23\bin

    to compile
    C:\ Documents and settings\ User> javac hello.java

    the error it shows is still the same

  8. #8
    pawanmutalik is offline Member
    Join Date
    Feb 2011
    Posts
    5
    Rep Power
    0

    Default

    i think javac command is working..coz wen i enter just javac on command prompt,
    i get a long text on all the possible options that i can use on javac..

  9. #9
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,782
    Rep Power
    7

    Default

    Placing your java file(s) in the bin directory is a bad idea. Create a directory somewhere else on your hard drive and place the java file(s) there. Then cd to that directory and compile and run it.

  10. #10
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Junky gave the perfect advice, you can also use the -cp or -classpath flag which lets you choose the classpath you want to search for the file in.

    if you save the .java file in
    c:\javacode\myclasses

    You can compile it from anywhere with
    Java Code:
    javac -cp \javacode\myclasses classname.java
    For more details check out:
    javac - Java programming language compiler

    It's also probably better to get comfortable compiling and running programs without setting the classpath variable.

  11. #11
    pawanmutalik is offline Member
    Join Date
    Feb 2011
    Posts
    5
    Rep Power
    0

Similar Threads

  1. Problems with javac
    By gkoef in forum New To Java
    Replies: 14
    Last Post: 09-07-2010, 10:17 AM
  2. javac
    By PhilArmstrong in forum New To Java
    Replies: 31
    Last Post: 11-21-2009, 03:46 PM
  3. javac?
    By sardare in forum Eclipse
    Replies: 1
    Last Post: 06-14-2008, 02:06 AM
  4. javac DOS
    By rdunne in forum New To Java
    Replies: 3
    Last Post: 01-01-2008, 11:49 AM
  5. Help with javaC
    By Daniel in forum New To Java
    Replies: 2
    Last Post: 07-04-2007, 02:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •