6

I recently read that java was made so it can run about anywhere, like for example on a toaster. So this question popped in mind, can you run Java Virtual Machine and java programs on a fresh computer/laptop that has no operating system like from a disk or a USB ? If so, could a java program written on my windows run on the JVM on the No OS computer too ?

I tried searching on google, but i could not find anything related

Thanks

user2578273
  • 111
  • 1
  • 6
  • "Toaster" means J2ME (Java micro edition for embedded computing). Probably not what one commonly refers to as Java. (I think there is an even more compact version to run on smart cards, such as the Apple Pay chip). – Thilo Oct 28 '14 at 06:18
  • 1
    Or Android (which is open source). J2ME is pretty darn long in the tooth these days. – markspace Oct 28 '14 at 06:20
  • 4
    Conceivably you could build an OS that implements the VM at the core, but now days, you're probably more likely see the OS as a cut down linux kernel, maybe with a cut down version of Java... – MadProgrammer Oct 28 '14 at 06:22
  • 1
    There have been some processors that use the same instruction set, I always thought [JOP](http://en.wikipedia.org/wiki/Java_Optimized_Processor) was the coolest. – Jason C Oct 28 '14 at 06:26
  • Theoretically, yes, you can design a computer to run a JVM as the OS, so the JVM interacts directly with the hardware. Generally, this is impractical unless you are building a dedicated embedded device with limited resources. – CharlieS Oct 28 '14 at 06:31

2 Answers2

14

The Java specifications don't require the JVM to run on top of an OS; that's much of the reason behind the careful wording in the specs. BEA's Project Bare Metal was a JVM effort to run directly on hardware without an operating system, and OSv is a developing a JVM that will run on a hypervisor but without the need for a traditional OS.

Additionally, embedded Java implementations, such as in smart cards, generally don't use a runtime JVM. Instead, the JVM is an ahead-of-time compiler that translates bytecode into machine code for the target platform.

chrylis -cautiouslyoptimistic-
  • 75,269
  • 21
  • 115
  • 152
0

JMV has lots of implementations in all kinds of OS. but it is a program that uses OS... so you must have one to run the JVM on it.

After that the java program that you will write can run on any JVM on any OS...

Ahiel
  • 493
  • 3
  • 11