是否可以使用java制作操作系统?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1988196/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is it possible to make an operating system using java?
提问by giri
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
我想知道是否有可能制作一个像 windows-xp 这样用 C 语言编写的操作,就像我可以用 java 编写那样,这样我就可以拥有与用 C 编写的相同的功能
采纳答案by Eli Bendersky
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.
理论上是的,但您仍然需要一些低级汇编代码来引导将在机器上运行的 Java VM,以及用于访问硬件驱动程序的低级代码。
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.
鉴于 Sun Microsystems 的 Java 是当今最主要的面向对象语言之一,因此尝试使用基于 Java 的操作系统也就不足为奇了。在这方面,理想情况下,内核将包含支持 JVM 所需的最低限度。这是此类操作系统中唯一必须用 Java 以外的语言编写的组件。建立在 JVM 和基本硬件支持的基础上,可以用 Java 编写操作系统的其余部分;甚至系统中传统上用 C 等低级语言编写的部分,例如设备驱动程序,也可以用 Java 编写。
此类操作系统的尝试示例包括 JX、JNode 和 JavaOS。
回答by Ignacio Vazquez-Abrams
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.
这取决于您认为的“功能”。如果您指的是图形界面、花哨的窗口效果等,那么可以,尽管您将需要汇编语言或 C 语言用于最低位(即与 I/O 端口等接口)。如果您还将 Windows ABI 作为一项功能包含在内,那么它会变得更加困难,因为它们遵循 Pascal 调用约定。
回答by Ron Gejman
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).
理论上,是的。但是您需要以某种方式使用低级代码运行 Java VM(除非您想将 Java 编译为汇编,这在不牺牲 Java 的许多功能的情况下可能是不可能的)。
回答by sesteel
回答by manuel aldana
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).
操作系统更接近硬件(如驱动程序)。在我看来,这不是 Java 的领域(只是问题域操作系统的错误解决方案)。
回答by iCodeSometime
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
回答by magneto12321
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.
正如上面提到的其他人,它已经是尝试者。Jnode 是唯一一个经受住了时间考验并且正在积极开发的产品,尽管他们已经多年没有发布新版本了。但是,如果您查看他们的 Git 提交,就会发现在我撰写本文时,他们正在准备即将发布的版本。我是 Java 的粉丝,期待发布。讨厌像 Java 这样冗长的命令式语言的人对这个想法感到畏缩,但它并不适合所有人。
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.
在硬件中实现 Java 字节码的想法也很有趣。我不认为这会随处可见,因为 Java 的优势在于您无需过多担心硬件。您只需要获得一个 Java 操作系统,它就可以在任何 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.
我认为 Java 在操作系统领域的真正力量是虚拟化。我想不出更好的方法来拥有虚拟操作系统,因为 Java 无处不在。
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.
正如上面提到的其他海报,它不能在没有 Java 硬件实现的情况下完全用 Java 实现。Jnode 完全用汇编和 Java 编写。但是所有现代操作系统都使用某种汇编语言。