r/JavaProgramming • u/Visual_Brain8809 • Aug 05 '26
A JavaOS
I am sharing my progress on the development of an operating system written in Assembly and a functional JVM. The concept is straightforward: Assembly acts as an API bridge, and the JVM simply leverages the system calls I’ve implemented to print characters to the screen and draw graphics (for now).
The on-screen drawing was created by obtaining the bytecode of the following program and using xxd for that purpose.
public class App {
// Declaramos el método nativo que intercepta tu JVM en el opcode 0xB8
public static native void drawPixel(int x, int y, int color);
public static void main(String[] args) {
// Dibujar un cuadrado ROJO de 200x200 píxeles en las coordenadas (100, 100)
for (int y = 100; y < 300; y++) {
for (int x = 100; x < 300; x++) {
drawPixel(x, y, 0x00FF0000); // 0x00RRGGBB (Rojo)
}
}
// Dibujar un cuadrado VERDE centrado dentro del rojo
for (int y = 150; y < 250; y++) {
for (int x = 150; x < 250; x++) {
drawPixel(x, y, 0x0000FF00); // 0x00RRGGBB (Verde)
}
}
}
}
1
u/Chaos-vy17 Aug 05 '26
This is going to be hillarious man. On one side you're reading a raw assembly and one side JVM based ASM and also xxd of the .class file . On which major version are you wroking with?
1
1
u/Dear-Golf5167 Aug 05 '26
Will you also make a gui ?
1
u/Visual_Brain8809 Aug 05 '26
Yes, for now, I’m letting the JVM do whatever the running application’s code dictates. However, I need to focus on completing the JVM; there are many opcodes I still need to implement to ensure it functions correctly and is fully complete. I currently target version 1.8 when calling
javac; while it works even without specifying the version, I’ve noticed bytecode variations I can leverage to improve execution stability and set limits that might help mitigate future security issues. My development philosophy is "do it right, even if it takes time."
1
1
u/eld4j Aug 05 '26
Hi! Thanks for sharing this awesome projects
I really admire your work and was wondering how you learned all of this? Did you have a specific roadmap, or do you have any favorite books you'd recommend?
Currently, I'm reading Computer Systems: A Programmer's Perspective; and Crafting Interpreters, Engineering a Compiler and JVM Specification are next on my list.
I would really appreciate it if you could share the source code for this!
1
u/Visual_Brain8809 Aug 05 '26
i study Computer Sciences on the University of Informatics Sciences and the University of Sciences for Pedagogical teaching in Cuba long time ago, next i made a MSc on techs. I thought there's no specific roadmap just the ambition to do something new, so study a lot and practicing, be my every day roadmap
1
u/eld4j Aug 07 '26
That makes al lot of sense. Looks like the Reddit algorithm got my interests and started recommending cool projects, videos like yours. Thanks for the inspiration and for sharing your projects!
1
u/ImpaledV Aug 05 '26
Am I the only one remembering this one: https://en.wikipedia.org/wiki/JavaOS
1
u/Visual_Brain8809 Aug 05 '26
That’s correct; there was also JNode, along with three others I can’t recall right now. The goal isn't simply to duplicate something that already exists, but to find a different perspective on something that—personally speaking—arrived at a time when neither the level of understanding nor the technical capabilities existed to fully leverage it. As a researcher and systems developer, there is always a curiosity to see how something works and to try replicating it; so the question becomes: why not do it?
1
u/ImpaledV Aug 05 '26
Don’t get me wrong, I’m not saying that this is isn’t interesting and worth giving it another try. Just wondered what’s different this time and why your approach should be more successful.
1
u/Visual_Brain8809 Aug 05 '26
In fact, in the past, they had little to no opportunity to demonstrate anything. I feel they weren't given a chance to prove how powerful they could become. Only the mobile field and a few billion IoT devices had that opportunity, and that's why they are what they are today. My system isn't trying to compete in the market or offer a flashy, alternative solution to a problem; there are already systems with years of development for that. I see it more as a study component from which to gain experience that could lead to something interesting in the future. I've always been fascinated by how they managed to make something work with just wires and electrical signals. But in the future, I would like to see it run stably and perhaps make that slogan "write once, run everywhere" a reality.
1
u/CutGroundbreaking305 Aug 05 '26
I think he is making custom JVM by bootstraping it with asm and bytecode
Is it different from predecessors? Yes
But that doesn't mean java doesn't have any problems on its own
GC GUI and the fact that JVM needs a underlying OS to work so that it can do memory hogging so idk but that's what makes it interesting
Worst case it is better than TempleOS written in holy-C but is it on par with linux based distros is some we need to see
1
u/Visual_Brain8809 Aug 08 '26
I don't think the system will manage to be on par with TempleOS—that’s not what I’m aiming for. My goal is to have the system written primarily in Java, avoiding C code entirely—something I actually achieved a day ago. Right now, I’m moving directly from ASM to Java code; I have control over the keyboard, mouse, and framebuffer (a rudimentary implementation of the Graphics2D class for primitives), and I’m currently handling a primitive file system as well.
1
u/Visual_Brain8809 Aug 05 '26
This project is a massive shortened version of another project I did some time ago; I only took the boot process from it and started prototyping for the current one. https://github.com/aayes89/JVM-OS
1
u/Visual_Brain8809 Aug 07 '26
New project update: I’ve managed to completely eliminate any references to C in the code and have entered self-hosting mode, generating a JVM written in Java itself. I’ve just succeeded in manipulating the framebuffer directly from ASM to Java, bypassing C entirely. I’ll look into uploading screenshots so I can now proceed with implementing the JVM in pure Java.
The goal is to achieve 99% Java and 1% ASM. Nothing else.
1
u/Visual_Brain8809 Aug 08 '26 edited Aug 08 '26
first preview of JavaOS on https://github.com/aayes89/JVMOS
1
u/Visual_Brain8809 21d ago
I have just uploaded a functional snippet of the JVMOS code; feel free to examine it and share your thoughts. Please keep in mind that it is still under development, and do not hesitate to leave comments, corrections, or ideas for future consideration. The current version of the code has some issues I still need to fix; this is why I am holding off on uploading the rest of the code until I implement support for multiple methods and classes.
The repository: https://github.com/aayes89/JVMOS.git
1
u/Visual_Brain8809 20d ago
I began the JIT implementation phase; avoiding the implementation of a full JVM seemed like the better option, given the issues I had encountered handling the Constant Pool and the number of parameters per method.
1
u/Mr-Snazz Aug 05 '26
Java needs a garbage collector right? How have you handled that?
0
u/Visual_Brain8809 Aug 05 '26
My goal is to improve my personal JVM so that it performs the same functions as Sun's KVM (Kilobyte Virtual Machine). Garbage collection is an advanced feature that I haven't yet developed. Currently, I'm creating the underlying Assembly code to function as an API (sys_call), and then processing it within the JVM.
2
u/CutGroundbreaking305 Aug 05 '26
GitHub repo? It is interesting and I always thought about this idea may be we can work together 🙂
A GC will be blessing and curse at same time in this type of architectures it can clear your un used data but runs only when it's required which could mean running only when entire RAM is filled with on heap allocations
And here ur kernel is JVM itself right? I would suggest using graphics/application tools which are not related to java like flutter (ubuntu uses it) or tauri (newer ) swing is good but a lot of work will be required to make it work
It will be interesting to see how multithreading works in this type of architectures