single source file program (java --source 11

netbeans at netbeans at
Tue Feb 19 14:30:00 UTC 2019

Dear Devs."


  1) shebang support so ignore first line with "#"
  2) support to "<" and "|" so to read it from standard input
  3) extends for two source file
     //file exec-cmd that it is anywhere on PATH
     //cjava is just link to java command

     #!/usr/bin/env cjava --source 11 --delegation cmd
     public class GeneralCommand {
        onXY() ...

     //in working directory in file "cmd"

     public class Command extends GeneralCommand {

        onXY() ...

     > exec-cmd
     So after execution as usual compile GeneralCommand class
     and then regarding to "--delegation" 
     it will be searching for "cmd" in working directory
     if it finds match then compile it and instead of calling 
     main method of General Command call main method of 

     As this is was even previously easily realizable by jjs 
     via load() to have common share logic for any command,
     but exact execution-logic or just written custom 
     handlers or configurations separated into more files.

     So only installation-care is to place exec-cmd somewhere 
     PATH and creation link cjava to exact java and of 
     course write own exact command. And when you 
     extend exect-cmd you just replace it and everything 
     is working (so no need for merging and so on).
     On Microsoft Windows

     > exec-cmd //exect-cmd.cmd | .bat

            java --source 11 --delegation %CD%/cmd %~dp0/cmd-exec

More information about the jdk-dev mailing list