Skip to main content
blog title image

2 minute read - Java For Testers

How to learn to code Java without using a 'main' method

Mar 6, 2015

In the book Java For Testers, I teach Java slightly differently to make it easier to learn. Let me explain how.

When you learn Java, one of the first things you traditionally learn is how to create a ‘main’ method.

That makes sense right?

After all:

  • You’re learning how to write applications. 
  • Applications need to be compiled. 
  • A compiled Java application needs a main method to run.

Of course, you also need to know:

  • How to use ‘javac’ to compile the program
  • How to use ‘java’ to run the program

And you might need to know:

jar cmf helloworld.jar HelloWorld.class
java -jar helloworld.jar

And if you are beginning your learning in how to program Java, then you don’t even understand the code you’ve written to write “Hello World” to the console

System.out.println("Hello World");

I wonder why people prefer to learn scripting languages like Python and Ruby?

But, you don’t have to learn all this when you start, especially not when you want to learn to write automation code rather than application code.

You could:

  • Write all your code in an IDE
  • Write JUnit @Test methods
  • Run the JUnit @Test methods from the IDE 
  • (right click on the method name and choose “Run”)

That way, you can start to learn the Java programming language. And use it to “do stuff” without all the baggage.

That’s why in the book Java For Testers, you learn to write all your code as JUnit @Test methods.

Java For Testers is a tutorial guide. Learn Java by writing JUnit @Test code.

Java For Testers ebook available from: