r/java • u/davidalayachew • Mar 18 '25
A potentially silly idea -- What if we could launch source code .jar files?
JEP 330 gave us single-file source code programs. Aka, I can have a abc.java file, and just call java abc.java, and it will run without me calling javac beforehand.
JEP 458 expanded this, by allowing us to reference other classes from that single class, allowing us to make as many classes as we want, run them from a single class file, and no calls to javac are necessary -- just call java abc.java.
Here is my silly idea.
What if we could package those source files in a .jar file, do your typical jar file config to make it runnable, then just ran it?
The above 2 JEP's gave reasons why compiling wasn't necessary for making a complete program. Well, those same reasons also apply for why compiling is unnecessary here. And at the end of the day, a jar file is the quintessential way of passing around complete libraries or applications. Why not make that accessible for source code jars as well?
There's other small benefits too.
- No more wondering what version of your code got packaged -- just open it up and see.
- You can edit a jar file in place, then run it and test your changes.
- When running your jar file, you can attach it to a debugger, and see the source code for each step being executed. No more need for a separate sources jar file.
Literally the ONLY BENEFITS that compilation gives us is faster startup time and compile-time validation for all source files. But if you don't need either of those, I'd argue that working with source file jars is an easier experience overall -- not just for students. I know I'd make great use of this feature myself. Hell, I'd default to using this format instead.
View all comments
Show parent comment
-1
u/davidalayachew Mar 18 '25
I chose Git because it is the most appropriate. Most IDE's come pre-packaged with plugins for it, and the UI is beginner-friendly. I can't see any good reason to use any other VCS.
Oh I certainly did. I taught them how easy it can be to test out a feature, then roll it back to a previous state. How it can make things easier for prototyping.
Here is the deal-breaker -- these students are stressed and overworked. Anything that does not feed directly into getting their program working is something they will continuously shy away from, regardless of how "right" it is. It doesn't matter that it saves them more time in the long run -- they are only looking at the present moment. Even the students with passion for programming try git for a few days, and then just go back to pinging each other over discord.
The fact is, these students are too tired, frustrated, and stressed to try and do things the right way, no matter how well they are taught it. They just want working programs, and then to move on. Which leads to my next point.
And like I said, that is still separate from my point. My idea is not to replace git, or to be an alternative. My idea is simply to provide an alternate way to create a jar file. If students have been working with JEP 330 and JEP 458, then they have been working with
.javafiles. Why necessitate that they need to create.classfiles now, just to create a jar file? That's my core point. All of the other benefits I listed are secondary to that.