Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javac: invalid flag: myfirstapp.java

 
Swapnil Singh
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • 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.
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
its still not working
 
Swapnil Singh
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • 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
 
Campbell Ritchie
Sheriff
Pie
Posts: 50235
79
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
oh.. thank you i didn't know its case sensitive..
 
Campbell Ritchie
Sheriff
Pie
Posts: 50235
79
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic