Saiem Irfan
3 min readSep 30, 2020

--

The Sandwich

My introduction to technical writing, as I remember it, came in 6th grade science. We were assigned to write a set of instructions to create a peanut butter jelly sandwich. We were also shown a video similar to this one which clearly demonstrated the level of technicality which came into play here. The next day, 5 groups submitted their procedures, and five sandwiches were created. Two of them had a jar of peanut butter in between two slices of bread. Two more had a knife in place of the jar. The last one didn’t even have stacked slices of bread.

The fact of the matter is, even in such simple tasks such as creating a sandwich, technical writing requires immense precision. However, take too much time being precise, and you’ve written an entire essay on how to open a jar and your reader may not even finish reading what you’ve written. There’s a fine balance between concision and precision, and technical writing is the monster in the middle.

How To Use Java Through Command-line — A Small Technical Piece

This assumes you are using git bash on windows

So you wanna be a command-line chad? Well you’ve come to the wrong place. A more appropriate way to get used to command line would be through Python, as it allows for args and kwargs which allow for more flexibility when running your program of choice. However, you’re stuck with Java.

First things first, you want to download the executable for your choice in version of a maintained JDK (And, obviously, your operating system). I’ll be downloading Java 15 (but you would be better of downloading a version with LTS). Open the executable once it’s downloaded and follow the instructions the installation wizard gives you. If done properly, you should see something similar to figure 1.

Figure 1. Successful installation message for Java SE Development Kit 15

Next, create a new file called test.java and fill it with the following code snippet, but rename the class from Main to test. By simply adding the file location as an option to the java command in your command line, you should have mastered this foreign art.

Figure 2. Using java through a command line interface

That is, unless, you’ve download java 8. Given I’m approaching a rather strict word count, I won’t elaborate on why. But choosing to run test.java with java 8 will result in an error as shown by figure 3.

Figure 3. Running the java command in java 8 results in an error

To fix this error, do the following. Find the location where you installed your jdk and navigate to bin. You should see a javac executable here. Remember the location of this executable and through command line, set up a bashrc, and alias ‘javac’ to the javac executable location.

Figure 4. How you get to your .bashrc / create one
Figure 5. An example of aliasing javac using the default install location

Now, to execute test.java, execute the file first using the javac command and follow up by running only the class test as an option to the java command.

Figure 6. Compiling and executing the test class

Congratulations! You’ve finally mastered the art of running java programs through the command line. You are one step closer to being the coolest kid on the block.

~Saiem

--

--

Saiem Irfan
0 Followers

Studying Computer Science at UTM