• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

could not compile a program

 
nikhil govind
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
error comes as

java:invalid flag program.java
javac <options> <sourcefiles>
what should be done...
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please show the command line you have typed.
 
Giovanni Lima
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nikhil govind wrote:error comes as

java:invalid flag program.java
javac <options> <sourcefiles>
what should be done...


Are you using Windows? Check your enviroment vars.. check the spaces or try quote each value on the path like: "C:\BLABL";"C\OTHER" ...
 
Darryl Burke
Bartender
Posts: 5116
11
Java Netbeans IDE Opera
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Giovanni Lima wrote:Are you using Windows? Check your enviroment vars.. check the spaces or try quote each value on the path like: "C:\BLABL";"C\OTHER" ...

No, that kind of mistake leads to a different error. As Christophe has already said, we need to see the exact command line that led to this.

And welcome to the Ranch, Giovanni and Nikhil!
 
nikhil govind
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your early replies
the command prompt i have set the correct path and have all the other programs compiled correctly
it runs correct in eclipse also

i wrote simply

javac program.java

it had some other files dependencies but all were compiled without error...
yes its windows 7
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Typing "javac program.java" produces the following error ?

Really ? Exactly that error ?
 
nikhil govind
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you don't have a file called "javac.bat" somewhere, do you ?
 
Campbell Ritchie
Sheriff
Pie
Posts: 47293
52
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . and welcome to the Ranch both nikhil govind and Giovanni Lima
 
Giovanni Lima
Greenhorn
Posts: 13
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Darry Burke
@Campbell Ritchie
thanks

Look at this thread http://www.coderanch.com/t/453337/java/java/Invalid-Flag-Error-when-javac
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nikhil, it is important that you tell us exactly what command you typed in to compile your program. If you did that earlier, it would have been much easier to help you. Because you didn't tell us exactly what you did, we have to guess, and it takes much longer to find out what exactly the problem is.

The topic that Giovanni posted a link to explains that if you have directories with spaces in your classpath, you can get this error. The solution is to enclose the path names that contain spaces in "quotes".
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic