Results 1 to 2 of 2
  1. #1
    69B is offline Member
    Join Date
    Jul 2013
    Rep Power

    Question javac: Invalid flag: ... HELP [with pictures]

    so it's been 2 years i have this problem. When i'm trying to compile my file (compile.bat) ,it gives me this error:

    Java Code:
    @echo off
    title Client - Compiler
    javac -d bin -sourcepath src src/*
    I have tried to chnge the compile code to that : Yet it still shows the same error.

    Java Code:
    @echo off
    title Client Compiler
    echo starting...
    "C:\Program Files\Java\jdk1.7.0_25\bin\javac" -cp lib/*; -d bin -sourcepath src src/*.java 

    after many many hours of research , i haven't found any guide or simillar error on youtube. I did find in google and on this forum but none of the solutions/explications are suitable to my problem :(.
    I have seen somewhere that it has something to do with Environement Variables. SO here are mines.

    =classpath - ''C:\Program Files\Java\jdk1.7.0_25\bin'';''%CLASSPATH%'';
    =path - C:\Program Files\Java\jdk1.7.0_25\bin;

    BOT (system variables)
    =path - C:\Program Files\Java\jdk1.7.0_25\bin;
    =CLASSPATH - .;''C:\Program Files\Java\jdk1.7.0_25\bin'';''C:\Program Files\Java\jre7\lib\ext\''

    I think i have all my quotes and semi-collons set-up the right way. I ignore the problem.
    Please help me out .

    AND PLEASE I MEAN REALLY PLEASE, if you're trying to explain , explain it the deepest way . Because i'm quite new to all that :S.
    THANKS !

    PS- I don't know if i posted this in the right section (i'm new to this forum). If so ,asking for a forum-moderator to moove it ,thank you.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power

    Default Re: javac: Invalid flag: ... HELP [with pictures]

    javac -d bin -sourcepath src src/*

    Not sure why you've got sourcepath in there as that is rarely needed (I've never needed it in 15 years).
    It's only required if you are compiling stuff in multiple source directories.
    I suspect it's partly this causing the problem.

    Having a classpath defined as an environment variable is not a Good Thing. It means all your work will be forced to use the same classpath, and this is again rarely the case.
    You should define the classpath either in the BAT file or directly in the javac command (as in your second example). That way you control exactly what is needed for a particular project.

    Note that that classpath should have '.', which means "current directory", or the path to the src directory you are going to compile.

    You want src/*.java, not *, as it appears to be trying to compile the .bat file. (Or *.java if you are in the src directory).
    And then you want to be running this from the directory containing the src directory.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Invalid flag error
    By Javellotto in forum New To Java
    Replies: 7
    Last Post: 01-15-2013, 10:59 AM
  2. Invalid flag problem
    By Cheynems in forum New To Java
    Replies: 6
    Last Post: 09-16-2011, 07:56 AM
  3. javac: invalid flag: Files\Java\jdk1.6.0_18;C:\Program
    By darrell22 in forum New To Java
    Replies: 5
    Last Post: 02-09-2010, 09:27 AM
  4. Replies: 3
    Last Post: 08-14-2009, 01:57 PM
  5. Replies: 2
    Last Post: 07-30-2007, 09:55 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts