javago
an example compileAndGo script using Java

Wrap Java code in a compileAndGo script, as in the example below. Once-only compilation is automatic; class files are cached out of sight; source and invocation script are both in the one file. See the modtime script for a Java example requiring a library in the classpath.

Here's how it works.

1 Z% ./javago
Hello, folks of World!
2 Z% 

Here’s the javago script. After that I’ll show you how to do the same thing with gcj.

#!/usr/bin/env compileAndGo
langauge = java
!#

public class javago {
  public static void main(String[] args) {
    System.out.println("Hello, " + (args.length >= 1 ? args[0] : "folks of World") + "!");
  }
}

 

gcj (Gnu compiler for Java)

Just as simple:

#!/usr/bin/env compileAndGo
langauge = java
compiler = gcj
!#

public class javago {
  public static void main(String[] args) {
    System.out.println("Hello, " + (args.length >= 1 ? args[0] : "folks of World") + "!");
  }
}

 

Encapsulating binary resource files as Java source

Perhaps there is a tool somewhere that will encapsulate a binary resource file into a Java source file as static initialization data. I imagine a command something like this:
   binaryToJava javax.swing.ImageIcon icon.gif MyIcon.java

(“Hello, folks of World!” is the Goon Show variant of “Hello, world!”)


http://Yost.com/computers/compileAndGo/javago.html - this page
2004-03-03 Created
2005-07-24 Modified to use the new compileAndGo program
2006-05-13 use simplest possible examples
2005-11-06 End the header with !# per compileAndGo 5.0