Hello Java: An Introduction
I had asked around for tips on interviewing and one book kept popping back up: Cracking the Coding Interview, 6th Edition by Gayle Laakmann McDowell.

Since this book kept popping up, I thought I’d buy it and start studying from it.
For the record, I had never been introduced to Java before, so when I first got it, I was super confused about what language it was written in. The book never explicitly states that the programming language would be in Java. I was overwhelmed by the intimidation of learning a new language, so away I put it on my bookshelf and never again did I touch it until two months later, when I felt I was ready to give it a shot again and learn a new language.
I thought I’d start off by just learning how to print “Hello World” to the console or terminal. This would be the tutorial that I found and would code along with: https://www.guru99.com/first-java-program.html
In order to compile and run my Java programs via the command line prompts
javac
and
java
I would have to the Java JDK or Java SE Development kits. For MacOS, I downloaded both the disk image file (.dmg) and the .tar.gz file just to be safe. I couldn’t compile my program without it before.
From there, open up your text editor of choice, whether it be Notepad or Atom. I prefer to use Microsoft Visual Studio.
From there, type in the following code.
class A {
public static void main(String args[]){
System.out.println("Hello World");
}
}
You’re doing a few things here.
- You’re declaring a class with the name “A”.
- You’re declaring the main method. I believe Java looks for the main method and runs it every time you run the program. So you’d have to reference all other methods from this main method if you want to run them.
- You’re printing out the line “Hello World” to the terminal.
Cool. Now that we have that, make sure to save your program with the extension filename .java to ensure that the computer knows it’s a java program that’s being compiled. Per the tutorial, I named mine FirstProgram.java .
Now let’s compile! In the terminal/command prompt, run the following commands. Make sure you’re in the directory where you saved this Java file.
javac FirstProgram.java
This compiles your program as a Java program. If you go to your working directory/folder, you’ll see that a file named A.class has been created.
Now to execute the code:
java A
This executes the A class and you should see “Hello World” print to the command prompt!

That’s all for now, folks! And Happy Holidays to you all!