Results 1 to 9 of 9
  1. #1
    hawkinsjb1 is offline Member
    Join Date
    May 2015
    Posts
    4
    Rep Power
    0

    Default Classpath will be the death of me PLEASE

    Downloaded jdk 1.8.0_45 today and the path and classpath both for some reason have caused me issues, but with most being resolved there seems to be one problem i cannot fix.

    Very simple after saving the proper HelloWorld script to HelloWorld.java and i go to compile in cmd with javac -Helloworld command and i recieve the following error:

    javac: invalid flag: -helloworld
    Usage: javac <options> <source files>
    use -help blah blah

    After some googling ive come to a conclusion that it is probably? my classpath. And well i completely deleted the CLASSPATH variable in the enviromental variables tab, and i want to use it for this instead of using -cp in cmd (which i dont get how to do either but i will learn). So now to create a new classpath I was told i needed to find out my current directory and also my java_home/lib thing in order to perform the compiler, my CLASSFILE currently says this:

    C:\WINDOWS\system32;C:\Program Files\Java\jdk1.8.0_45\lib;

    i still receive the invalid flag errbor, what should my classpath be set to?? Please dont link me to guides about setting classpaths, I have read every single one known to man and also have set millions of classpaths but i always get suck here, any help would be appreciated, preferably just giving me the classpath to copy

    WINDOWS 7 UPDATED JAVA - 8u45

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    26

    Default Re: Classpath will be the death of me PLEASE

    Forget about the classpath. Remove any customization you may have done already.

    Where did you learn to prefix '-' before the name of the file to be compiled? Get rid of it.

    Better go through Lesson: The "Hello World!" Application (The Java™ Tutorials > Getting Started)

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Classpath will be the death of me PLEASE

    I wrote an article too which goes a little more in-depth:

    I want to learn Java: 02. Getting dirty with the JDK tools
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,422
    Blog Entries
    7
    Rep Power
    28

    Default Re: Classpath will be the death of me PLEASE

    Quote Originally Posted by hawkinsjb1 View Post
    javac: invalid flag: -helloworld
    Usage: javac <options> <source files>
    use -help blah blah
    It all boils down to knowing your tools; you shouldn't have written 'blah blah' but you should've read what the compiler had to say to you: -helloworld isn't a valid flag value, so you should've read your command line where you supplied it. Typing 'javac -help' should've shown you how you should use the compiler; the classpath has (almost) nothing to do with it; it is just a list of direcrtories and resource files where the Java class loaded should look for .class files and/or other resources.

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

  5. #5
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    14

    Default Re: Classpath will be the death of me PLEASE

    Quote Originally Posted by JosAH View Post
    you shouldn't have written 'blah blah'
    James T. Kirk would agree with you. "No more blah, blah, blah!" From the episode, "Miri."

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Classpath will be the death of me PLEASE

    Quote Originally Posted by jim829 View Post
    James T. Kirk would agree with you. "No more blah, blah, blah!" From the episode, "Miri."

    Regards,
    Jim
    One should be extra proud when a fictional character agrees with you.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  7. #7
    hawkinsjb1 is offline Member
    Join Date
    May 2015
    Posts
    4
    Rep Power
    0

    Default Re: Classpath will be the death of me PLEASE

    The -help line simply reads -help for a list of possible options and i didnt want to type the rest, i used the command and it doesnt really teach me how to use the compiler otherwise i wouldnt be here, you guys were right i used the '-' improperly and without using it i run into another error:

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

    classpath is currently set to .; and when i do the command javac -cp . HelloWorld.java i receive the same error, any ideas?

  8. #8
    hawkinsjb1 is offline Member
    Join Date
    May 2015
    Posts
    4
    Rep Power
    0

    Default Re: Classpath will be the death of me PLEASE

    Forgive my little knowledge, but this issue is probably related to where i saved the HelloWorld.java text, I simply clicked saved and it went into my documents, is there a specific location to save it to

  9. #9
    hawkinsjb1 is offline Member
    Join Date
    May 2015
    Posts
    4
    Rep Power
    0

    Default Re: Classpath will be the death of me PLEASE

    I am so sorry for the triple post guys, this thread can be locked, i saved the .java in a new folder directly in my C:\ then used that as the classfile and it worked

Similar Threads

  1. Replies: 1
    Last Post: 05-03-2011, 02:28 AM

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
  •