This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread 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 Android Security Essentials Live Lessons this week in the Android 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: 38064
    
  22
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: 38064
    
  22
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
 
Similar Threads
Javac: File Not Found
Importing packages from a .jar
problems compiling for java 1.5/5.0
problem in enhanced for loop
how to name and save the Television interface