• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

could not compile a program

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
error comes as

java:invalid flag program.java
javac <options> <sourcefiles>
what should be done...
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please show the command line you have typed.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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" ...
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Typing "javac program.java" produces the following error ?

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

Look at this thread https://coderanch.com/t/453337/java/java/Invalid-Flag-Error-when-javac
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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".
 
catch it before it slithers away! Oh wait, it's a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic