Zombie.java:
public class Zombie {
public static void main (String [] args) {
System.out.println("Brains!");
}
}
> javac Zombie.java
> java Zombie
> jar cvf Zombies.jar Zombie.class
> java -cp Zombies.jar Zombie
Zombie.java:
public class Zombie {
public static void main (String [] args) {
String zombieMsg = "Brains!";
System.out.println(zombieMsg);
}
}
Zombie.java:
public class Zombie {
public static void main (String [] args) {
String zombieMsg = args[0];
System.out.println(zombieMsg);
}
}
> javac Zombie.java
> java Zombie "I want brains!"
Zombie.java:
public class Zombie {
public static void main (String [] args) {
if(args.length > 0) {
String zombieMsg = args[0];
System.out.println(zombieMsg);
} else {
System.out.println("Enter a zombie message");
}
}
}