• 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

javac: invalid flag: myfirstapp.java

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
im tryin to compile my very first java program but its showin some error while tryin it on cmd,
it shows something like this-


C:\javapractice>javac myfirstapp.java\
javac: invalid flag: myfirstapp.java\
Usage: javac <options><source files>
use -help for possible options

please help.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't type a backslash on the end of your source file name like that.
 
Swapnil Singh
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
its still not working
 
Swapnil Singh
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
its showing-

C:\javapractice>javac myfirstapp.java
myfirstapp.java:1: error: class myfirstapp is public, should be declared in a file named myfirstapp.java
public class myfirstapp {
^
1 error
 
Marshal
Posts: 79178
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It should be obvious from the message. You need to make the name of the class and the name of the file correspond. If there is the slightest spelling diffference, the compiler won’t accept it. Your class ought to start with Capital Letters. Remember there is a difference between Something.java and something.java.
 
Swapnil Singh
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oh.. thank you:) i didn't know its case sensitive..
 
Campbell Ritchie
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Didn’t whoever is teaching you Java tell you it’s case‑sensitive?

Well done sorting it out, and welcome to the Ranch
reply
    Bookmark Topic Watch Topic
  • New Topic