←back to thread

Java Hello World, LLVM Edition

(www.javaadvent.com)
200 points ingve | 3 comments | | HN request time: 0s | source
Show context
troymc ◴[] No.46181738[source]
I made a poster showing how one might write a Hello World program in 39 different programming languages, and even different versions of some common languages like Java:

https://troymcconaghy.blog/2025/01/13/39-hello-world-program...

replies(4): >>46181790 #>>46181936 #>>46182649 #>>46183494 #
pron ◴[] No.46181936[source]
Nice, but as of JDK 25 (the preview JEP 445 has become the permanent JEP 512), the canonical Hello World in Java is:

    void main() {
        IO.println("Hello World");
    }
replies(3): >>46182156 #>>46184122 #>>46188449 #
1. prmoustache ◴[] No.46184122[source]
Not a java developer but why the void? Shouldn't your main function and program return an integer?
replies(2): >>46184384 #>>46184677 #
2. tadfisher ◴[] No.46184384[source]
I believe that is a C-ism, where the C runtime calls your main() and exits the process with the return value. The Java equivalent is System.exit(int status).
3. gavinray ◴[] No.46184677[source]
The return type of a Java main is the JVM platform return type

Sending system signals is external to the JVM platform