Reputation: 13
I am experiencing a very annoying problem to me, imagine I compile the file FooBar.java:
$ javac FooBar.java
It compiles sucefully and then I run it as usual:
$ java FooBar < in.txt
I get the output as expected, the deal is, if I change the source code (FooBar.java) to print something else and compile it again I get the same output as the first time!
This is really making me mad... is there any cache for the javac? Even if I delete FooBar.class and recompile I get the output from the early source code. The only way I found to solve this is to delete FooBar.java and create a new file with a diferent name (I just copy-pasted the code), this works.
This bug (?) is really bugging me. I've searched for a solution or an explanation to why this happens but with no luck.
This seems to be related to my problem but not completely as I am not using any IDE and the Classpath points to my working folder: http://www.coderanch.com/t/519372/java/java/Executing-Old-Code
I would like to find out what's causing this as I don't want to make a new file everytime I update source code... I'm on Windows with Java 1.6.0_27
Thanks for reading...
Upvotes: 0
Views: 3303
Reputation: 6581
The problem won't be caching. Try this:
Upvotes: 0
Reputation: 310893
Is there a package declaration? You may have put in a package declaration since you first compiled it. If you have package foo.bar the compiler will create the .class file in foo/bar/FooBar.class and you should run it with java foo.bar.FooBar
. If there is no package it will create ./FooBar.class and you run it via java FooBar
.
Upvotes: 1