BitFiber
BitFiber

Reputation: 476

Eclipse ignoring my commenting

I'm having a bit of a strange problem in Eclipse 3.7.0 on Linux Mint 12. I have a code snippet here to get an integer from the user using JOptionPane, and originally wanted to limit the user to choosing the numbers 0 through 10. However, I'm now trying to change it to accept numbers between -10 and 10, so I commented out the conditional. When I run it in Eclipse, it still limits me to 0 through 10, but compiling and running from the terminal works fine. Here's part of my code, but I think the problem is with my setup, not the code:

try {
    degree = Integer.parseInt(input);
    /*if(degree > 10 || degree < 0) JOptionPane.showMessageDialog(null, "Please enter integer between 0 and 10.", "Error", JOptionPane.ERROR_MESSAGE);
    else*/ valid = true;
} catch(NumberFormatException e) {
    JOptionPane.showMessageDialog(null, "That is not a valid integer.", "Error", JOptionPane.ERROR_MESSAGE);
}

EDIT: I just noticed a red exclamation point in my projects list, but I can't find where it says what's wrong.

Upvotes: 0

Views: 4143

Answers (2)

JesseBoyd
JesseBoyd

Reputation: 1096

running Project/Clean fixed the eclipse ignoring my commented out code and showing compile errors.

Upvotes: 1

Stephen C
Stephen C

Reputation: 718788

Yes. The problem is something to do with your setup.

Clearly, the compiled classes that you run when you launch the application from Eclipse are different to those that you created from the command line.

We can safely eliminate the Eclipse compiler as a plausible cause. The Java compiler won't ignore your changes ... if it runs ... and that includes commenting out things.

Here are some more plausible explanations :

  • The code has not been recompiled in Eclipse.

    • This could happen if you are updating source files outside of Eclipse, and Eclipse isn't aware of this. Select the project in the project view and use F5 to refresh.

    • This could also happen if you've turned off automatic building, and / or if you are ignoring compilation errors.

  • Your Eclipse is in a knot. (It happens sometimes ...) Restart Eclipse. If that makes no difference, restart Eclipse with the -clean command line option.

  • It is also possible that you've done something to your Eclipse project's build path or the launcher configuration to make this happen. The latter you could test by creating a new launcher configuration.

Upvotes: 3

Related Questions