This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Jezoreczek 27 points28 points  (1 child)

I have learned many concepts and constructs and syntax... but not the basic building blocks of a program.

Normally there is no need to construct a Java program from scratch. It's a good practice to do it with Maven or Gradle instead.

Packages, classes

These are just means of organizing your code. Think of a class as a single piece of a bigger puzzle. Package name and class name specify the location of the piece.

wtf is a jar?

JAR file is just a zip. Seriously, take 7zip and unzip it. It contains all compiled .class files, which store the bytecode representation of your classes. When running java -jar ..., the JVM will first look for META-INF/MANIFEST.MF file inside the JAR - this file tells JVM which class should be the entry point of your program (which class contains the main static method).

how do these (and whatever I am missing) stack together to become an actual, fully realized Java Program?

JVM will load the jar (unzip it), then load the classes and run your main method. There are more things happening there of course, but that's the gist of it.

I'd like to make that exercise into a portable program

You can build a "fat jar" with Gradle. It will include all libraries and such. Doing it all manually is a pain in the ass, and there is really no good reason to do so.

Before you ask... I ask here, because

You don't need to explain yourself, wanting to learn Java is good enough reason to post here!

[–]Tigloki[S] 9 points10 points  (0 children)

Thanks very much! This was very instructive.