Results 1 to 7 of 7
Like Tree1Likes
  • 1 Post By Tolls

Thread: .java to .class issue

  1. #1
    Vantrax is offline Member
    Join Date
    Feb 2013
    Posts
    5
    Rep Power
    0

    Default .java to .class issue

    Hello all

    I made the HelloWorldApp as suggested by "Hello World!" for Microsoft Windows (The Java™ Tutorials > Getting Started > The "Hello World!" Application) but I ran into an error that couldn't be fixed following the list of errors (or I must have done something wrong, which could be realistically be the solution)

    I ran command prompt, ordered it to go to the map where my .java file was stored, entered (after patching it in advanced system configuration) PATH javac HelloWorldApp.java, hit enter, typed dir and I could not see a .class file.
    Command prompt didn't give me any error at all, I have saved a couple printscreens to show you guys.
    (the computer has dutch as main language, but it doesn't make the problem unclear imo)

    The printscreens:






    Final notes: yes I'm running vista, I know it sucks, never knew it could possibly make programming more difficult, I'm planning on buying a better computer; I copied the helloworld code from the site when it didn't compile to .class the first time to make sure it was not the code's fault.


    Thank you for your attention and I hope you can find the answer to my question soon, I can't wait to run my HelloWorldApp.class file :)

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,987
    Rep Power
    9

    Default Re: .java to .class issue

    What error are you actually getting when you run javac on your .java file?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default Re: .java to .class issue

    Hi there you've go some things mixed up. PATH needs to include the java/bin directory, i.e. where the java.exe and javac.exe files are. Easy test is : c:>java -version
    That should print out the version of your JDK.
    The classpath tells the VM where to look for your .java file.
    So you go to the direcory where the .java file is and type javac -cp. HelloWorldApp.java
    Now you should see the .class file
    To run it you type in the same dirctory: java HelloWorldApp
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  4. #4
    Vantrax is offline Member
    Join Date
    Feb 2013
    Posts
    5
    Rep Power
    0

    Default Re: .java to .class issue

    In the printscreen you can see that PATH stands for my current java version, after typing "javac -cp. HelloWorldApp.java" nothing happened, I think this is mainly my computer's fault, but I can be wrong. if it creates a .class file, doesn't it automatically store in the same directory as the original .java file?

    EDIT: When I entered "javac -cp. HelloWorldApp.java" this showed up:

    javac: invalid flag: -cp.
    Usage: javac <options> <source files>
    use -help for a list of possible options
    Last edited by Vantrax; 02-20-2013 at 04:05 PM.

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default Re: .java to .class issue

    Put a space between the 'cp' and the '.'
    Your earlier problem is down to you starting your command with 'PATH'.
    PhHein likes this.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  6. #6
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default Re: .java to .class issue

    Thanks, Tolls! Sorry Vantrax, bad typo from my side.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  7. #7
    Vantrax is offline Member
    Join Date
    Feb 2013
    Posts
    5
    Rep Power
    0

    Default Re: .java to .class issue

    It solved the problem!! I now have a .class file, thanks guys :)

Similar Threads

  1. [SOLVED] Class paths and Packages issue
    By kammce in forum New To Java
    Replies: 14
    Last Post: 07-12-2012, 05:10 AM
  2. Timer Class Issue
    By CuppaCoffee in forum New To Java
    Replies: 3
    Last Post: 01-05-2012, 10:31 PM
  3. Issue in method anonymous class in GWT
    By ankit01 in forum GWT
    Replies: 0
    Last Post: 05-16-2011, 11:25 AM
  4. Class cast issue
    By AedonetLIRA in forum New To Java
    Replies: 5
    Last Post: 11-19-2010, 04:34 PM
  5. Calendar class issue
    By OlegKo in forum New To Java
    Replies: 3
    Last Post: 10-24-2010, 06:36 PM

Tags for this Thread

Posting Permissions

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