Noel Enete
Program Generation


Skeleton Java applications and Java applets can be generated automatically using tools that come with the nuggets.

Application Generation


If you have set up your Java environment as described above, you have access to many of the nugget tools from the command line. The tool that I use most often is the application generator. It

  • creates a directory
  • places you into the directory
  • creates a "Hello World" source file
  • creates a script file for editing (x) your application
  • creates a script file for compiling (c) your application
  • creates a script file for running (r) your application

This quickly generates a functioning base point from which to create a program, or experiment with syntax problems.


In Windows. Invoke the tool like this:

1.22 C:\test>application MyApplication

1.22 C:\test\MyApplication>dir
 Volume in drive C has no label.
 Volume Serial Number is 3713-2A7B

 Directory of C:\test\MyApplication

09/03/99  08:32a                  .
09/03/99  08:32a                  ..
09/03/99  08:32a                   199 x.bat
09/03/99  08:32a                    51 c.bat
09/03/99  08:32a                    47 r.bat
09/03/99  08:32a                   110 t.bat
09/03/99  08:32a                   158 MyApplication.java
               7 File(s)            565 bytes
                            691,404,800 bytes free

As you can see, it has created the subdirectory MyApplication, changed to that directory, and created a number of script files for editing, compiling, and running the program.

By default, the editor that is launched when the x script is run is notepad. But if you look at the x.bat source, you can override it by assigning an environment variable. The following steps cause wordpad to be launched instead of notepad.

1.22 C:\test\MyApplication>set JUMPSTARTEDITOR=start wordpad
1.22 C:\test\MyApplication>x


In Linux. Invoke the tool like this:

1.17 [ndenete@PCSN709199 test]$ . application MyApplication
1.17 [ndenete@PCSN709199 MyApplication]$ ls -l
total 9
-rw-rw-r--   1 ndenete  ndenete       158 Sep  2 17:58 MyApplication.java
-rwxr--r--   1 ndenete  ndenete        50 Sep  2 17:58 c
-rw-rw-r--   1 ndenete  ndenete        51 Sep  2 17:58 c.bat
-rwxr--r--   1 ndenete  ndenete        56 Sep  2 17:58 r
-rw-rw-r--   1 ndenete  ndenete        47 Sep  2 17:58 r.bat
-rwxr--r--   1 ndenete  ndenete       109 Sep  2 17:58 t
-rw-rw-r--   1 ndenete  ndenete       110 Sep  2 17:58 t.bat
-rwxr--r--   1 ndenete  ndenete       108 Sep  2 17:58 x
-rw-rw-r--   1 ndenete  ndenete       199 Sep  2 17:58 x.bat

The following steps cause emacs to be launched instead of vi.

1.17 [ndenete@PCSN709199 test]$ export JUMPSTARTEDITOR=emacs
1.17 [ndenete@PCSN709199 test]$ x

Applet Generation


With your Java environment setup as described above, you also have access to my second most used tool -- the applet generator. It

  • creates a directory
  • places you into the directory
  • creates a "Hello World" applet source file
  • creates an HTML file to launch the applet
  • creates a script file for editing (x) your applet
  • creates a script file for compiling (c) your applet
  • creates a script file for running (r) your applet in the appletviewer

This quickly generates a functioning base point from which to create a full applet, or experiment with syntax problems.


In Windows. Invoke the tool like this:

1.22 C:\test>applet MyApplet

1.22 C:\test\MYAPPLET>dir
 Volume in drive C has no label.
 Volume Serial Number is 3713-2A7B

 Directory of C:\java\MYAPPLET

09/03/99  08:34a                  .
09/03/99  08:34a                  ..
09/03/99  08:34a                   194 x.bat
09/03/99  08:34a                    51 c.bat
09/03/99  08:34a                    28 r.bat
09/03/99  08:34a                    81 t.bat
09/03/99  08:34a                   166 MyApplet.html
09/03/99  08:34a                   213 MyApplet.java
               8 File(s)            733 bytes
                            691,339,264 bytes free

As you can see, it has created the subdirectory MyApplet, changed to that directory, and created a number of script files for editing, compiling, and running the program.

The steps to change the default editor are the same as for the application generator above.

1.22 C:\test\MyApplication>set JUMPSTARTEDITOR=start wordpad
1.22 C:\test\MyApplication>x


In Linux. Invoke the tool like this:

1.17 [ndenete@PCSN709199 test]$ . applet MyApplet
1.17 [ndenete@PCSN709199 MyApplet]$ ls -l
total 10
-rw-rw-r--   1 ndenete  ndenete       166 Sep  2 18:26 MyApplet.html
-rw-rw-r--   1 ndenete  ndenete       213 Sep  2 18:26 MyApplet.java
-rwxr--r--   1 ndenete  ndenete        50 Sep  2 18:26 c
-rw-rw-r--   1 ndenete  ndenete        51 Sep  2 18:26 c.bat
-rwxr--r--   1 ndenete  ndenete        37 Sep  2 18:26 r
-rw-rw-r--   1 ndenete  ndenete        28 Sep  2 18:26 r.bat
-rwxr--r--   1 ndenete  ndenete        80 Sep  2 18:26 t
-rw-rw-r--   1 ndenete  ndenete        81 Sep  2 18:26 t.bat
-rwxr--r--   1 ndenete  ndenete       103 Sep  2 18:26 x
-rw-rw-r--   1 ndenete  ndenete       194 Sep  2 18:26 x.bat

The following steps cause emacs to be launched instead of vi.

1.17 [ndenete@PCSN709199 test]$ export JUMPSTARTEDITOR=emacs
1.17 [ndenete@PCSN709199 test]$ x



by Noel Enete . . . www.enete.com . . . noel@enete.com