Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why eclipse doesn't recompile last changes made to my Java classes?

Tags:

java

eclipse

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?

like image 301
JavaDeveloper Avatar asked Jun 04 '26 17:06

JavaDeveloper


1 Answers

  1. Have Build Automatically checked

enter image description here

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".

enter image description here

like image 126
Brian Avatar answered Jun 06 '26 05:06

Brian