The enhancements described below are fully backward compatible with existing java code.
1. Default package and class name for main() method
While Java requires that the 'entrypoint' point is called
main() it needs you to specify the class name containing that method in the
MANIFEST.MF file or on the command line.
If Java could pick a 'default' class name for the main method, eg
app.Startup this would reduce the need for all that extra config. It can still allow overriding the main class from the manifest or command line, but if it couldn't find anything there, it could just default to trying to execute the
2. Java native dependency management
While Maven and Gradle allow you to do highly complicated builds, the vast majority of times that's not needed. If you are creating microservices, you really just need to:
- Download dependencies
- Compile source code
- Package everything into a Jar
There should be a Java native file format that's just a list of dependencies alongside the language version being used. Eg
Java version 11
The java cli could just take this as input, download the dependencies in say
~/.java-deps and compile your source code against it.
Go already does this with great success. It would mean that vast majority of developers, especially those new to Java, wouldnt need to learn about Maven or Gradle and all the complexities they bring.
3. Self-contained jar support
Java still expects you to separately ship all the dependent libraries. Sure, there are plugins for Maven and Gradle to create an 'uber jar', and even Spring Boot does it out of the box. However, since this is how most people want to ship their java apps in a dockerized world it should be supported out of the box. Java should have a command-line option, say
--uberjar to build a self-contained jar containing all the dependencies.
With the above enhacements implemented, in a new java project you would just need to create:
app.Startupclass with a
dependencies.txtfile listing your dependencies
Now you can just write your code and use the Java CLI like to create a distributable jar:
java --uberjar dependencies.txt --source src myapp.jar
That's it! You won't need to learn about Maven/Gradle or any other config option to get started with Java.
One can only hope...