File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes could not compile a program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "could not compile a program" Watch "could not compile a program" New topic
Author

could not compile a program

nikhil govind
Ranch Hand

Joined: Mar 08, 2011
Posts: 31
error comes as

java:invalid flag program.java
javac <options> <sourcefiles>
what should be done...
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Please show the command line you have typed.


[My Blog]
All roads lead to JavaRanch
Giovanni Lima
Greenhorn

Joined: Mar 08, 2011
Posts: 13
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

Joined: May 03, 2008
Posts: 4541
    
    5

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!


luck, db
There are no new questions, but there may be new answers.
nikhil govind
Ranch Hand

Joined: Mar 08, 2011
Posts: 31
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

Typing "javac program.java" produces the following error ?

Really ? Exactly that error ?
nikhil govind
Ranch Hand

Joined: Mar 08, 2011
Posts: 31
yes
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

you don't have a file called "javac.bat" somewhere, do you ?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38765
    
  23
. . . and welcome to the Ranch both nikhil govind and Giovanni Lima
Giovanni Lima
Greenhorn

Joined: Mar 08, 2011
Posts: 13
@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

Joined: Aug 16, 2005
Posts: 14144
    
  18

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".


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: could not compile a program