1

Possible Duplicate:
Is it possible to make an operating system using java?

Using a language that compiles to Java byte code, such as Java or Clojure, would it be theoretically possible to write an entire operating system that works completely in the Java Virtual Machine?

Community
  • 1
  • 1
Lincoln Bergeson
  • 3,301
  • 5
  • 36
  • 53
  • 1
    Well, what runs the JVM? (And yes, there are such attempts, and yes, there are hardware based VM implementations. So, please search first!) –  Nov 25 '12 at 04:58

3 Answers3

3

It would only be possible if the CPU were capable of executing Java bytecode (see: Java processor). Otherwise, you would need some native machine instructions to initialize the hardware and interpret or JIT compile the bytecode.

David Brown
  • 35,411
  • 11
  • 83
  • 132
2

There is a (now abandoned) project, called JavaOS which sought to do just what you suggest.

hd1
  • 33,938
  • 5
  • 80
  • 91
  • The OP is asking if it's possible to write an OS in *nothing but* Java. JavaOS ran on top of a native microkernel. – David Brown Nov 25 '12 at 05:04
2

It depends what you mean by "entire operating system": the most credible approach would be a hybrid OS which uses Java for the "user space" and something like Linux as the underlying OS for hardware access.

Some things to consider:

  • Obviously the JVM itself needs to run on something. This might be a native JVM implementation running on another OS or it might be hardware, but either way it would need to use something other than pure Java at some point in the stack. Hence the suggestion of something like Linux to play this role.
  • Unless you allow linking of extra native code, your interactions with the underlying hardware / platform would be dictated by what is available in the Java runtime environment (e.g. File abstractions etc. for file access). This is certainly enough to implement a working OS shell, but might not be enough to implement direct hardware access to many devices, for example.
  • For a modern OS, you'd probably want to use OpenGL for the graphics (or a similar high performance graphics library). That's not in the standard Java runtime environment at present, so you would need to find a solution to include this (e.g. LWJGL)
mikera
  • 105,238
  • 25
  • 256
  • 415