June 2018
Beginner
722 pages
18h 47m
English
Let's use the first program we created in Chapter 4, Your First Java Project, to demonstrate how to use the command line. Here is the program we wrote then:
package com.packt.javapath.ch04demo;import com.packt.javapath.ch04demo.math.SimpleMath;public class MyApplication { public static void main(String[] args) { int i = Integer.parseInt(args[0]); SimpleMath simpleMath = new SimpleMath(); int result = simpleMath.multiplyByTwo(i); System.out.println(i + " * 2 = " + result); }}
To run it from a command line, it has to be compiled first using the javac command. An IDE that uses Maven places the .class file in the directory target/classes. If you go into the root directory of your project or just click
Read now
Unlock full access