r/javahelp • u/MalakiiThePotato • Apr 21 '22
Is it possible to make an operating system using only Java?
I want to see if it's possible to make an operating system (kernel and everything) using Java, I'm not asking how, I'm just wondering if it's possible.
5
u/8igg7e5 Apr 21 '22
Not really. Even JavaOS had a C++ JVM and I don't doubt other parts were in C/C++/Assembly too - without control over memory layout I doubt drivers were in Java.
1
u/GoogleBen Apr 22 '22
I disagree unless you mean to say "practically, not really". You could offload a lot of the work of memory management etc. to specialized hardware and with a Java processor you don't need a JVM. It would probably be terribly inefficient and far more work than a similar OS in a language with pointers and no GC, but possible.
1
u/8igg7e5 Apr 22 '22
Don't those all confirm my statement, leaving issues like IO (which needs precise memory layout assumptions to be even remotely practical), and GC, to non-java code - implementing parts of the JVM in native code (at least one even leaving handling of some of the more complex byte-codes outside the processor too).
By changing the Java specification, to allow Java to assume more about layout, it probably could be made possible. Making it practical might not be such a small change.
It's almost certainly not a serious direction of interest now. JIT compilation has proven effective and where JIT isn't a practical option, AOT compilation may be and removes almost all motivation to try and build Java-on-chip or Java-as-OS solutions.
1
u/GoogleBen Apr 23 '22
I certainly won't argue practicality - Java is horribly suited to be an OS language in a million different ways. In terms of possibility as an academic question, I think really the only thing to be necessary for a basic OS would be a Java processor to remove the need for a JVM.
Using a Java processor actually takes care of your IO concerns; IO in Java (e.g. through
java.io.File) relies on native methods that are JVM-specific. The Java processor can simply bind those native methods to hardware functions, and you're good to go.Again, it's not remotely practical, and without "cheating" a little bit with stdlib extensions won't be very featureful, but definitely fits the definitions of both "possible" and "OS". Besides, with a Java processor being a CPU that only runs Java bytecode (and if you didn't check the Wikipedia link, they've been made before), what would run on it besides a Java OS?
2
3
u/Just_Another_Scott Software Engineer 😎 Apr 21 '22
Sure.
See Small Talk. Smalltalk is an ancestors of Java. They created an entire OS using the Smalltalk Virtual Machine. You can pretty much do the same with Java.
•
u/AutoModerator Apr 21 '22
Please ensure that:
Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
You include any and all error messages in full
You ask clear questions
You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.
Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar
If any of the above points is not met, your post can and will be removed without further warning.
Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.
Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.
Code blocks look like this:
You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.
If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.
To potential helpers
Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.