Can a Java program work without its file?

I am new to this, but essentially: there are programs and there are processes. A program is a file that starts a process when it is executed.

You cannot delete a program if there is a process associated with it. The process must be killed first.

This is similar to Java programs. However, I am curious why - isn't everything loaded in the JVM?

+8
java
source share
2 answers

"Remote file" includes som OS semantics. On Unix / Linux, a file can be deleted, and all open file descriptors remain valid. When the last open file descriptor disappears, the space occupied by the deleted file is returned to the free space pool.

Windows may have other mechanisms.

+4
source share

The JVM works as a Just-In-Time (JIT) compiler. There are many sources of information about compiling JIT, but basically, how a Java program works, it will encounter part of the necessary program, these parts of the program are in .class files. These .class files are just an intermediate form of Java code (this is not exactly Java code, but not quite machine code). Obviously, runtime compilation (JIT) requires resources (CPU cycles) and therefore time. Thus, the JVM loads only the parts of the program that are necessary to minimize the processor cycles.

But yes, your understanding of the process / programs is correct. To summarize: a process is an executable instance of a program. This running program can then spawn even more processes or threads to do the work.

+2
source share

All Articles