This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes javac: invalid flag: myfirstapp.java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "javac: invalid flag: myfirstapp.java" Watch "javac: invalid flag: myfirstapp.java" New topic
Author

javac: invalid flag: myfirstapp.java

Swapnil Singh
Greenhorn

Joined: Jul 12, 2012
Posts: 4
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
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Don't type a backslash on the end of your source file name like that.
Swapnil Singh
Greenhorn

Joined: Jul 12, 2012
Posts: 4
its still not working
Swapnil Singh
Greenhorn

Joined: Jul 12, 2012
Posts: 4
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

Joined: Oct 13, 2005
Posts: 38426
    
  23
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

Joined: Jul 12, 2012
Posts: 4
oh.. thank you i didn't know its case sensitive..
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38426
    
  23
Didn’t whoever is teaching you Java tell you it’s case‑sensitive?

Well done sorting it out, and welcome to the Ranch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javac: invalid flag: myfirstapp.java