Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are java .class files needed after an application is running?

I had a hard time writing the title to this question, but here is my situation and what I am asking:

  • I have a Java project that I run "ant test" on to run the tests
  • The tests take about 10 minutes to run
  • Can I switch to a different Git branch in the middle of running these tests without consequences?
  • I want the tests to complete against the original code, and allow me to simply work on a different branch while that happens.

I guess the root of my question is: Are .class files needed after the application is loaded and running? Is the classes just stored in memory, and I don't need the files on the file system anymore? Or does it still access/read things on the filesystem?

Any insight or better understanding of what java needs for a running application is appreciated.

like image 396
Sean Adkinson Avatar asked Mar 07 '13 20:03

Sean Adkinson


2 Answers

Classes are loaded on demand. The classloader won't attempt to load a class until that class has been referenced. Therefore, removing class files from the classpath in the middle of a run would almost certainly cause failures.

like image 131
Mark Peters Avatar answered Oct 17 '22 23:10

Mark Peters


If you don't compile the .java files you're getting from Git to the same location while the test is running, you won't have a problem with the .class files - no matter how the IDE loads the classes.

like image 3
ddmps Avatar answered Oct 17 '22 22:10

ddmps