• 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

Compile error invalid flag

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have reviewed other posts and reviewed my code over and over! I cannot for the life of me figure out what it is asking for that I'm missing! I've checked the program itself to make sure the syntax was right and I've crossed checked everything trying to find out where the error may be coming from. I'm stomped. Please help.

error: invalid flag: FirstExample.class
Usage: javac <options> <source files>
use --help for a list of possible option s


FirstExample.java



File path for FirstExample.java
C:\ProgramData\Microsoft\Windows\Start Menu\Programs

File path for Java
C:\ProgramData\Microsoft\Windows\Start Menu\Programs


Staff note (Ron McLeod) :

MM - please use Code Tags when posting code

 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That seems to be related to how you're trying to run the program. What commands are you issuing to compile then run your program? The "flag" referred to is most likely to be something that is being interpreted as a command line flag so we need to see exactly what you're typing in at the command line and what the exactly error message is you're getting.
 
Melonie Morrell
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply. Here is what is on the command line:

C:\ProgramData\Microsoft\Start Menu\Programs>javac FirstExample.class
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
javac takes the .java file name, not the .class
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, when you run the program using the java command, you don't put the .class extension, just the class name. So,

C:\> javac FirstExample.java
C:\> java FirstExample
 
reply
    Bookmark Topic Watch Topic
  • New Topic