Reputation: 5660
I have a simple file with just 1 line that prints "Hello World" inside main. I execute it and it prints "Hello World" on eclipse console. Now when I change the string to "Bye world" it still prints "Hello World". Infact if I cause a syntax error by modifying println to prrrintln. it still prints "Hello World". What can cause eclipse to not use the latest file ? When I try to run it from command line, I get the following error:
bin> java WordBreakProblem.class
Error: Could not find or load main class WordBreakProblem.class
Is there a correlation between two issues here?
Upvotes: 2
Views: 10330
Reputation: 51
Have you re-saved the code? In eclipse you need to save the changes made otherwise it will run what is previously saved. Or potentially try rebuilding the path if it is not saved to the right area.
Upvotes: 1
Reputation: 85779
Eclipse by default recompiles the projects after saving a change. This is noticed by Project > Build Automatically. If this option is unchecked, eclipse won't recompile the workspace after saving a small change. IMO this is option is useless when you have too many projects/files and recompilation can take several minutes.
If you have disabled this option (like me), then check this other option in Window > Preferences > Run/Debug > Launching > Build (if required) before launching:
If this option is disabled, then no matter how many times you change the classes or resources in the project, you will have to manually fire a build for the project(s) before launching it.
Upvotes: 3
Reputation: 13573
2. The correct way to run WordBreakProblem class is
java WordBreakProblem
instead of
java WordBreakProblem.class
Also make sure you compile the java source code into WordBreakProblem.class by using
javac WordBreakProblem.java
before doing step 2.
3. If the code still doesn't refresh, try "clean".
Upvotes: 7