Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Objects (Retired) Meet Objects Creating Classes

Timothy Flanagan
Timothy Flanagan
713 Points

Why do I keep getting an invalid flag error?

When I try to compile and run I get this message:

javac: invalid flag: %%

Usage: javac [options] [source files]

use -help for a list of possible options

But with arrow brackets instead of regular brackets. Sorry, I don't know how to input it here so it shows up properly!

My code is the exact same, as far as I can see, as the code in the video :(

5 Answers

Timothy Flanagan
Timothy Flanagan
713 Points
public class Example {

    public static void main(String[] args) {
        // Your amazing code goes here...
        System.out.println("We are making a new Pez Dispenser.");
        PezDispenser dispenser = new PezDispenser();
        System.out.printf("The dispenser character is %s\n",
                          dispenser.mCharacterName);
    }
}
Timothy Flanagan
Timothy Flanagan
713 Points

Oy. I figured it out. It's so dumb, I'm afraid to say it. I put %% instead of && when I was running the command. Noob apologies.

Haha. It happens. Good luck with future programming!

It would help if you posted your code between three ticks.

code here 

the ` is located just below the escape key, at least on windows.

I did some research, and an invalid flag error is based on the command you are putting into the console. Make sure there are no spaces in the file and the file name is spelled correctly.

Timothy Flanagan
Timothy Flanagan
713 Points

None that I can find :/ Everything seems to be spelled correctly.