JRE reads old class after compiling

M

mkn

Hello,

I have a weird problem: I wrote written a fairly simple Swing skeletal
application in Eclipse, compiled it to *.class files and moved it to
the target machine to test it. It worked just as expected so I added
some more stuff to it and moved it to the target machine again (and
again).

To my surprise running java -cp .\lib.jar;.\ RasDialer showed the
old application. Well, I cleared the project, recompiled, removed and
the result was still the same.

To figure out whether I had done something utterly silly I decompiled
the main class (where I had made some simple changes to buttons etc)
in the target workstation and the class was exactly as it should have
been - so it was compiled ok. I rebooted the computer to clean the
table. Still I get EXACTLY the same result whatever I do. As an
example the original main file had
setTitle("Swing App");

and I changed it to
setTitle("RAS Dialer Test");

and I can still see "Swing app" in the window title bar BUT "RAS
Dialer Test" in the decompiled class. If I rename the RasDialer.class
to xxx.class I will get the correct error message telling me that the
RasDialer class could not be found. This proves the fact that JRE is
at least trying to load the class from the correct file.

Where on EARTH is JRE fetching the classes from? What should I do? I
have done quite a bit of Java programming in the past but now I feel
pretty helpless. What is it that has changed? Does JRE cache the
classes in an uknown place or what? I feel like an idiot (which I may
very well be). As for the app it is using one external .jar and
one .dll file but these should not have any effect on the main class
loading, should they?

Markku
 
N

Nigel Wade

[snip]

Where on EARTH is JRE fetching the classes from? What should I do?

Try running java with the option -verbose:class.
This should tell you where it loads each class from.
 
M

mkn

Thanks, Nigel, I will try that. It seems to me, however, that there is
something severely wrong in every branch of my development/testing
machinery, anyhow. Very, very frustrating, indeed. I have done this
dozens and dozens of times before but now the whole thing fails to
work properly. I'll have some sleep first and if that does not help
I'll try some woodoo next :)

Markku
 
G

gryphon143

Are you opening child window too?
I have same problem and just changed setVisible to true and false in
child to make parent visible and not. The change in code was noticed
only after making this change. I still don't know what is happening to
my code :(
 
R

Roedy Green

To my surprise running java -cp .\lib.jar;.\ RasDialer showed the
old application. Well, I cleared the project, recompiled, removed and
the result was still the same.

If you have a tool like TakeCommand get it to search all your disks
for stray copies of the *.class file or *.jar files that might contain
the class. Perhaps some other copy is beating you to it on the
classpath.

you might like to implement a little student project to give you tool
to let you solve this easily.

See http://mindprod.com/project/which.html

--
Roedy Green Canadian Mind Products
http://mindprod.com
Refactor early. If you procrastinate, you will have
even more code to adjust based on the faulty design.
..
 
M

mkn

Thanks to all,

This mystery remained unsolved as such - I had no time to play with
it. FYI: There were no old .class files anywhere - the workstation was
clean and I kept cleaning it at each iteration.

What I did to solve the problem was quite drastic: I switched over to
NetBeans and repackaged the whole thing (including ALL libraries) to
a .jar package. Now every change I made was successful and visible
immediately.

I have no idea what was going on but the .jar solution was a good one
and even though I do not actually like Netbeans too much I will from
now on do my occasional Java stuff there. Eclipse stays as the tool
for PHP, Javascript and other Web things.

If I ever find out the cause I will let you know.

Markku
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top