These are the code samples that we built in class.
public class HelloJava { public static void main(String args[]) { String name = (args.length == 0) ? "World" : args[0]; System.out.println("Hello, " + name + "!"); } }
#!/usr/bin/perl use strict; use warnings; # try to compile HelloJava.java print "compiling... \n"; system('javac HelloJava.java'); # check exit code for errors if ($? != 0) { print "FAILED! $? : $!\n"; } # everything is ok, run code print "running... \n"; my $java_output = `java HelloJava`; # print output print "the command exited " . ($? >> 8) . "\n"; print "and the output was '$java_output'\n";