35

I wanna know is it possible to make an operating like windows-xp which is written in C language like can I write that in java so that I will have same features as written in C

skaffman
  • 398,947
  • 96
  • 818
  • 769
giri
  • 26,773
  • 63
  • 143
  • 176

6 Answers6

45

In theory yes, but you'll still have to have some low-level assembly code to bootstrap the Java VM that will run on the machine, and also low-level code for accessing hardware drivers.

From wikipedia:

Given that Sun Microsystems' Java is today one of the most dominant object-oriented languages, it is no surprise that Java-based operating systems have been attempted. In this area, ideally, the kernel would consist of the bare minimum required to support a JVM. This is the only component of such an operating system that would have to be written in a language other than Java. Built upon that JVM and basic hardware support, it would be possible to write the rest of the operating system in Java; even parts of the system that are more traditionally written in a lower-level language such as C, for example device drivers, can be written in Java.

Examples of attempts at such an operating system include JX, JNode and JavaOS.

Eli Bendersky
  • 263,248
  • 89
  • 350
  • 412
5

In theory, you could actually write the entire OS in Java with a Java processor. Basically it uses Java bytecode as the instruction set for the processor

iCodeSometime
  • 1,444
  • 15
  • 30
  • Is there any place I could go to do this? Like where to get the Java processor, how to hook it up etc... – KrystosTheOverlord Jun 04 '20 at 02:51
  • This was the best I could find https://www.electronicdesign.com/technologies/embedded-revolution/article/21772568/java-processors Or here's an open source version that says it's been implemented successfully using FPGAs https://opencores.org/projects/jop – iCodeSometime Jun 04 '20 at 19:43
5

In theory, yes. But you would need to somehow get the Java VM running using low-level code (unless you want to compile Java down to assembly, which probably isn't possible without sacrificing a lot of Java's features).

Ron Gejman
  • 6,135
  • 3
  • 25
  • 34
  • Jikes RVM (formerly IBM Jalapeno) and Sun Lab's Maxine are two examples of self-hosting JVMs. The former has around 1000 lines of C. Java is usually compiled down to machine code. – Tom Hawtin - tackline Jan 01 '10 at 11:34
  • @TomHawtin-tackline, did Maxine make it to the general public? – Thorbjørn Ravn Andersen Nov 19 '11 at 10:26
  • @Thorbjørn Ravn Andersen HotSpot is the Oracle production JVM. There still is JRockit, which will be phased out when important feature equivalents are added to HotSpot - no point in having two production JVMs. (There's also Java ME JVMs, which are likewise.) – Tom Hawtin - tackline Nov 19 '11 at 10:35
3

It depends on what you consider "features". If you mean graphical interface, fancy window effects, etc. then yes, although you will need assembly language or C for the very lowest bits (i.e., interfacing with I/O ports, etc.). If you also include the Windows ABIs as a feature then it gets harder since they follow Pascal calling conventions.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
3

operation systems are closer to the hardware (like drivers). in my view this it not the area of Java (just the wrong solution of the problem domain operating-system).

manuel aldana
  • 15,650
  • 9
  • 43
  • 50
3

As others mentioned above, it has already been attempter. Jnode is the only one that has withstood the test of time and is being actively worked on though they haven't released a new build in years. But if you look at their Git commits, they're working on an imminent release as I write this. I'm a fan of Java and look forward to the release. People who hate verbose imperative languages like Java cringe at the idea but it's not for everyone.

Interesting too is the idea of implementing Java byte code in hardware. I don't think that will go anywhere as the strength of Java is that you don't need to worry much about hardware. You just need to get a OS in Java and it can be run on any JVM.

I think the true power of Java in the OS domain is virtualisation. I can't think of a better way to have a virtual OS as Java is everywhere.

As other posters noted above, it can't be implemented completely in Java without a Java hardware implementation. Jnode is completely written in assembly and Java. But then all modern operating systems use some assembly language.