Skip to content

Latest commit

 

History

History

hello-world

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Hello, World!

Learn how to run a Java program that prints out Hello, world! to the console. See the source in HelloWorld.java.

Run like this:

# first compile the Java code into an executable Jar file
../gradlew build

# now run the Jar
java -jar build/libs/hello-world-all.jar

# also run with some arguments
java -jar build/libs/hello-world-all.jar a b c

🔥 Note you need to run build only after making changes to a source file.

Classes vs. Instances

Learn the difference between a class and a class instance. See the source in ClassVsInstance.java.

# first compile the Java code into an executable Jar file
../gradlew build

# now run the Jar
java -cp build/libs/hello-world-all.jar coding101.helloworld.ClassVsInstance

# also run with some arguments
java -cp build/libs/hello-world-all.jar coding101.helloworld.ClassVsInstance a b c

Imports and Logging

Learn about importing "outside" classes by using a logging framework to log messages instead of using System.out. See the source in ImportsAndLogging.java.

# first compile the Java code into an executable Jar file
../gradlew build

# now run the Jar
java -cp build/libs/hello-world-all.jar coding101.helloworld.ImportsAndLogging

# also run with some arguments
java -cp build/libs/hello-world-all.jar coding101.helloworld.ImportsAndLogging a b c