[drag-and-drop PIC] JavaArt Chapter 2.   Executing Pixels using Drag-and-Drop

 

This chapter does not appear in the book.

 

This is the second part of a two-chapter discussion on how to convert a Java program into an 'executable' image: a picture that can be executed just like its original source code. An example image is shown further down the page, on the right (enlarged by a factor of 4 to make it easier to see).

[JavaArt PIC]

This chapter is also about how to make a drag-and-drop Java application (called ExecutePixels). A user can drop an executable image onto ExecutePixel's icon, and have the image's program spring into life. This is surprisingly difficult to implement in Java alone, and I look at how to get some extra help from One-JAR, batch files, VBScript, and executable wrapper builders (e.g. launch4j). The image at the top of this page illustrates what I want to do.

When the image is dropped onto ExecutePixels, it's dynamically translated back into Java, compiled to byte codes, and passed to the JVM for execution. The translation, compilation, and execution are carried out by ExecutePixels "on-the-fly", without creating any temporary files on the machine (i.e. no Java or class files are saved).

The first chapter of this two-parter looked at implementing on-the-fly dynamic compilation with Java 6's Compiler API, and with the Janino compiler API. Due to Janino's small size, its open source license, and its more direct support for dynamic compilation, I'll employ Janino here.

 

Downloads


Navigation:


Dr. Andrew Davison
E-mail: ad@fivedots.coe.psu.ac.th
Back to my home page