Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse run old version of program

Tags:

java

eclipse

I have a problem while runing my application in eclipse. I make some edits like this:

String res = "newvalue";
System.out.println(res);

But when I run the application I still receive "oldvalue" in output. After this I tried to delete main() function - and I run application and I see "oldvalue" in output again.

Maybe it's some cache in JVM, or smth. else?

UPD:

It's 15:35 on my clock now. But in /bin folder I see .class files with 14:33 timestamp. I change source files (.java), press ctrl+f11 in eclipse and files in /bin folder are still 14:33 ...

UPD2:

After cleaning the project I receive the following problem:

The project was not built due to "Could not write file: D:\projects\NelderMead\bin\ru.". Fix the problem, then try refreshing this project and building it since it may be inconsistent

SOLUTION

The problem was that eclipse can't write file to the folder with spaces and UTF chars in it's name. So, I copy project to the new clean workspace and it runs without problems! Thx all for help detecting the problem!

like image 881
Dmitry Belaventsev Avatar asked Dec 10 '11 08:12

Dmitry Belaventsev


People also ask

How do I run a previous version of an Eclipse file?

File Navigation – Eclipse Shortcuts CTRL E – Open a file (editor) from within the list of all open files. CTRL PAGE UP or PAGE DOWN – Navigate to previous or next file from within the list of all open files. ALT <- or ALT -> – Go to previous or next edit positions from editor history list.

Why is Eclipse running a different project?

Trying to guess your problem: When you press the Run as button (White arrow in green circle), Eclipse doesn't run the program you're editing. Instead, it runs again the last program you executed. That's the reason why you see the output of another project: You're telling Eclipse to repeat its execution.

How do I run a different program in Eclipse?

The quickest way to run a Java program is by using the Package Explorer view. Right click on the java class that contains the main method. Select Run As → Java Application.

How do I fix run as none applicable in Eclipse?

Provide a public static void main(String[] args) method. You have to make sure that the editor containing your class (with main method) has the focus, otherwise Eclipse doesn't understand what you're trying to run.


1 Answers

You're executing an older class files, the reason could be

  • a compile error somewhere else (see problems view)

  • or your changed accidentally the source path so that the new source no longer gets compiled.

Try to clean the project and make sure the new classes are compiled to your output folder. The JVM doesn't have a cache for class files.

like image 80
stacker Avatar answered Sep 22 '22 09:09

stacker