Thread: Javac

Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    59
    Rep Power
    2

    Javac


    Hey everyone!


    I have been making my java programs and now want to be able to use CMD to run them. I have set up path ways and javac works but when I type javac Project2.java and hit enter it will not change it to a class file so I can run it in CMD. Any idea what I should be doing at this point?
  2. #2
  3. Java Junkie
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2004
    Location
    Mobile, Alabama
    Posts
    4,022
    Rep Power
    1285
    Originally Posted by Bykenhaal
    Hey everyone!


    I have been making my java programs and now want to be able to use CMD to run them. I have set up path ways and javac works but when I type javac Project2.java and hit enter it will not change it to a class file so I can run it in CMD. Any idea what I should be doing at this point?
    Are you sure a .class file isn't generated?

    If there are compile-time errors, it won't generate it.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    59
    Rep Power
    2
    I have hit the dir after I entered javac and this is what I was given.

    javac: file not found: Project2.java
    Usage: Javac <options> <source files>
    Use -help for a list of possible options
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    59
    Rep Power
    2
    Hey thanks for the help it turns out said file was not .java so it would not open. I fixed this and now I have the class file and .java thanks again.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    59
    Rep Power
    2

    Javac Problem


    I have gotten another javac problem.

    I go into Command prompt and find my file location. Then I type

    javac Progect.java

    I want to get the class file in other words compile. Can you Program Pros help me compile my program? Can I compile it any easier way? Any help would be great. I know you might know tricks that I have not learned yet. Thanks again.

    Bykenhaal
  10. #6
  11. Java Junkie
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2004
    Location
    Mobile, Alabama
    Posts
    4,022
    Rep Power
    1285
    I'm not sure what you're asking. javac is the way you compile the program
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    59
    Rep Power
    2
    Correct java is the way to compile java programs. The issue is it will not let me compile all the time. I did compiled a test java program the other day no problem. Today I tried to compile my project and I got this message in command prompt.

    java: file not found: Project2.java
    Usage: javac <options> <source files>
    use -help for a list of possible options

    So i tried to copy my program to notepad and put it right off my C: drive. It would not compile ever time I tried to find my project file it would just open it up "not in CMD in Notepad or NetBean".

    I hope I can learn to compile soon, I have been learning java for about a week now. Thanks for your time.
  14. #8
  15. Java Junkie
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2004
    Location
    Mobile, Alabama
    Posts
    4,022
    Rep Power
    1285
    The error means Program2.java is not in the current directory
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    59
    Rep Power
    2
    Thanks still working on this issue. I have found the folder when I get to the folder in command prompt like this the file just opens into netbean I am not able to use the dir or any other commands at the prompt.

    Any way to fix this issue, my files have been opened with netbean and notepad. I did not think it would be a problem to use javac at the prompt. It is as the files just open up in there respected program.
  18. #10
  19. Java Junkie
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2004
    Location
    Mobile, Alabama
    Posts
    4,022
    Rep Power
    1285
    When you say dir doesn't work what do you mean?
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    59
    Rep Power
    2
    Command prompt is telling me that the file is not a directory name but when I find desktop at the prompt and type dir I can see my Java file. When I type the name in Cd Program2.java it will open in Netbeans and the command prompt will just go back to C:\Users\Richard\Desktop

    My file is at C:\Users\Richard\Desktop\Project2.java
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    59
    Rep Power
    2
    I am not able to open the file so it is not possible to use the dir on my java project file. I was able to compile a folder before and it game me a class file with a lot of symbols and stuff. I want to get that again but can't.

    The main thing is to learn to compile my java files. I am told to use javac. I did the test lab and was able to get it all no problem. Now I have a project and can not do the compile. Possible from adding netbeans and notepad as a way to open my project??
  24. #13
  25. Java Junkie
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2004
    Location
    Mobile, Alabama
    Posts
    4,022
    Rep Power
    1285
    I'm not understanding what you mean about dir. dir gives you a list of files.

    You don't use dir on your program.

    What happens when you compile?
  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    59
    Rep Power
    2
    I get a error now telling me that I have a illegal exit. I do not understand. This seems to be the problem and reason why my program will not compile.
    Last edited by Bykenhaal; December 13th, 2013 at 06:24 PM.
  28. #15
  29. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    59
    Rep Power
    2
    C:\Users\Richard\Documents\NetBeansProjects\RandomNumberGame> javac RandomNumberGame.java
    javac: file not found: RandomNumberGame.java
    Usage: javac <option> <source files>
    use -help for a list of possible options

    When I do not use the .java tag when compiling I get this error.

    error: Class names 'RandomNumberGame' , are only accepted if anotation processing is explicitly requested

    1 error



    In NetBeans I do not save my work as .java as all my training videos do not tell me to do so. I think that maybe if I save them as .java and have the main as .java I will be able to compile.
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo