r/javahelp • u/EncryptedGhostShadow • Aug 19 '18
Question about JVM.
I have heard that Java is considered secure because the code actually runs in JVM and not on OS which is fine for most apps. For example if I am making a to-do app. But what if I want to make an app like CCleaner, it will need to delete some files (cache, junk files) from system. How will I be able to access system files as my code is contained inside JVM. If Java does allow me to access the system(read/write system files) via OS level API's then this statement that Java code runs only inside JVM and this is more secure than other programming languages is false.
If JVM internally checks what should and what should not be allowed to accessed then how is it different from, say python. Even their interpreter must be capable of making them as secure as Java.
2
u/[deleted] Aug 19 '18
That's not why it's secure, the jvm maps to the os. It still runs on the os.
Java can access system files without any issues.
Java code is converted to jvm bytecode. The jvm bytecode is run on the jvm. The jvm is run on the os. System calls in Java code as passed to the os by the jvm.
It isn't different than Python in that way, Python runs on a VM as well.