This problem will kill me!!!

Hi all;

I have a question about the class files. Let's say that I have some errors when I compile the code. I make the corrections and recompile the code again. However, for some reason the new class files are not overwriting the previous ones.

Therefore every time I compile the code I have to go to the file manager and delete the old

class files.

I am sure this a very basic problem. Has anybody got an idea. Is is because of the class path?

Thanks in advance

[500 byte] By [atanyera] at [2007-9-27 7:58:15]
# 1

Perhaps some more detail of your problem will help. Tell us exactly what you are doing. I do not have the problem you describe. It seems to me that unless you are using the -d option of javac, the .class file will appear in the same directory as the .java file so it will overwrite an existing .class file.

atmguya at 2007-7-8 12:32:17 > top of Java-index,Developer Tools,Java Compiler...
# 2

I think I might have the same problem as "atmguy" :

My program is not very long, but when I change anything in it, and then compile it, the old version of the .class files are the one who run in the program. The changes I just did are not made. If I delete the .class files and then compile the program it works just fine.

I am not using the -d option and can not understand how to get rid of the problem...Please help us!

lillanipa at 2007-7-8 12:32:17 > top of Java-index,Developer Tools,Java Compiler...
# 3

Hi,

I just solved the problem I had with my .class files!

I don't know if yours is the same of course, but when I made one file for each of mye classes in the program (had all the classes in the same file first) I did nor realize that I have to import all the files in every file I made. Therefore when I changed anything in the files that did not contain the main()-method in the program I had to delete all the .class files before compiling the program.

So check your import sentences, it might be some missing!

lillanipa at 2007-7-8 12:32:17 > top of Java-index,Developer Tools,Java Compiler...
# 4

Hi;

What I am doing is fairly simple. I wrote a program which has 15 java files linked to each other. When I run the program, if there are some errors I correct the problems and recompile my code again. However, for some reason the new class files are not overwriting the old class files. Therefore after the second compilation I still have the same errors that I had in the first compilation.

Every time I compile, I have to go to the file manager and delete the old class files. This process is very annoying and make me mad.

I complie and run my code with the statements:

javac test.java

java test

What is wrong?

> Perhaps some more detail of your problem will help.

> Tell us exactly what you are doing. I do not have

> the problem you describe. It seems to me that unless

> you are using the -d option of javac, the .class file

> will appear in the same directory as the .java file

> so it will overwrite an existing .class file.

atanyera at 2007-7-8 12:32:17 > top of Java-index,Developer Tools,Java Compiler...
# 5

Depending on the functionality of your compiler if you enter a command "javac Test.java" the only code that gets compiled is the Test.java source code. Sun's compiler will try to compile any classes that Test.java depends upon. If you have a lot of interdependencies, it is difficult to say whether the compiler will compile all classes that have changed. It's better to explicitly compile the classes you changed or to utilize "javac *.java" or write a batch file.

atmguya at 2007-7-8 12:32:17 > top of Java-index,Developer Tools,Java Compiler...