Permalink
Switch branches/tags
v1.1.2 v1.1.2-eap-77 v1.1.2-eap-73 v1.1.2-eap-69 v1.1.2-eap-44 v1.1.2-2 v1.1.1 v1.1.1-rc v1.1 v1.1-rc v1.1-beta2 v1.1-beta v1.1-M04 v1.1-M03 v1.0.7 v1.0.6 v1.0.5 v1.0.5-2 v1.0.4 v1.0.3 release/0.11.91.1.Idea141.19-141.175.3 release/0.11.91.1.Idea141.18-141.175.3 release/0.11.91.1.Idea141.17-141.175.3 release/0.11.91.1.Idea141.15-141.175.3 release/0.11.91.1.Idea141.14-141.175.3 release/0.11.91.1.Idea141.12-141.175.3 release/0.11.91.1.Idea141.11-141.175.3 release/0.11.91.1.Idea141.10-141.175.3 release/0.11.91.1.Idea141.9-141.175.3 release/0.11.91.1.Idea141.8-141.175.3 release/0.11.91.1.Idea139.12-139.1603.1 release/0.11.91.1.Idea139.11-139.1603.1 release/0.11.91.1.Idea139.9-139.1602.1 release/0.11.91.1.Idea139.8-139.1602.1 release/0.11.91.1.Idea139.6-139.1602.1 release/0.11.91.1.Idea139.5-139.1602.1 release/0.11.91.1.Idea139.4-139.1602.1 release/0.11.91.1.Idea139Release.5-139.1117.1 release/0.11.91.1.Idea139Release.4-139.1117.1 release/0.11.91.1.Idea139Release.2-139.1117.1 release/0.11.91.1.AndroidStudioCanary.14-140.2683.2 release/0.11.91.1.AndroidStudioCanary.13-140.2683.2 release/0.11.91.1.AndroidStudioCanary.12-140.2683.2 release/0.11.91.1.AndroidStudioCanary.11-140.2683.2 release/0.11.91.1.AndroidStudioCanary.10-140.2683.2 release/0.11.91.1.AndroidStudioCanary.9-140.2683.2 release/0.11.91.1.AndroidStudioCanary.7-140.2683.2 release/0.11.91.1.AndroidStudioCanary.6-140.2683.2 release/0.11.91.1.AndroidStudioCanary.5-140.2683.2 release/0.11.91.1.AndroidStudioCanary.4-140.2683.2 release/0.11.91.1.AndroidStudio.13-135.1306 release/0.11.91.1.AndroidStudio.12-135.1306 release/0.11.91.1.AndroidStudio.11-135.1306 release/0.11.91.1.AndroidStudio.10-135.1306 release/0.11.91.1.AndroidStudio.9-135.1306 release/0.11.91.1.AndroidStudio.8-135.1306 release/0.11.91.1.AndroidStudio.7-135.1306 release/0.11.91.1.AndroidStudio.6-135.1306 release/0.11.91.1.AndroidStudio.5-135.1306 release/0.11.91.1.AndroidStudio.4-135.1306 release/0.11.91.1.AndroidStudio.3-135.1306 release/0.11.65.Idea141.7 release/0.11.65.Idea139.2 release/0.11.65.AndroidStudioCanary.3-140.2683.2 release/0.11.65.AndroidStudioCanary.2 release/0.11.65.AndroidStudio.2 rc1.0.0-release-IJ143-78-143.2072 rc1.0.0-release-IJ143-75-143.2072 rc1.0.0-release-IJ143-70-143.2072 rc1.0.0-release-IJ143-69-143.2072 rc_/1.0.0-release-IJ141-56-141.2735.5 rc_/1.0.0-release-IJ141-54-141.2735.5 rc_/1.0.0-release-IJ141-42-141.2735.5 rc1.0.0-rc-1061-IJ143-72-143.2072 rc1.0.0-rc-1060-IJ143-71-143.2072 rc_/1.0.0-rc-1060-IJ141-57-141.2735.5 rc1.0.0-rc-1059-IJ143-67-143.2072 rc_/1.0.0-rc-1059-IJ141-52-141.2735.5 rc1.0.0-rc-1058-IJ143-66-143.2072 rc_/1.0.0-rc-1058-IJ141-51-141.2735.5 rc_/1.0.0-rc-1058-IJ141-41-141.2735.5 rc_/1.0.0-rc-1058-IJ141-40-141.2735.5 rc1.0.0-rc-1057-IJ143-65-143.2072 rc_/1.0.0-rc-1057-IJ141-50-141.2735.5 rc_/1.0.0-rc-1057-IJ141-49-141.2735.5 rc1.0.0-rc-1056-IJ143-64-143.2072 rc1.0.0-rc-1052-IJ143-63-143.2072 rc1.0.0-rc-1052-IJ143-62-143.2072 rc1.0.0-rc-1052-IJ143-61-143.2072 rc_/1.0.0-rc-1052-IJ141-48-141.2735.5 rc_/1.0.0-rc-1052-IJ141-47-141.2735.5 rc_/1.0.0-rc-1052-IJ141-46-141.2735.5 rc_/1.0.0-rc-1052-IJ141-39-141.2735.5 rc_/1.0.0-rc-1052-IJ141-38-141.2735.5 rc_/1.0.0-rc-1052-IJ141-37-141.2735.5 rc1.0.0-rc-1051-IJ143-60-143.2072 rc1.0.0-rc-1051-IJ143-59-143.2072 rc_/1.0.0-rc-1051-IJ141-45-141.2735.5 rc_/1.0.0-rc-1051-IJ141-44-141.2735.5 rc_/1.0.0-rc-1051-IJ141-36-141.2735.5
Nothing to show
Find file
1aae3ff Jul 19, 2012
42 lines (23 sloc) 1.99 KB

Sample Application

This (really simple ;) application shows how to use Kotlin and the maven plugin to generate JavaScript and invoke it from inside a HTML web page.

The source Hello.kt uses the kotlin.browser API to access the document property to modify the HTML.

Running the sample in a web browser

To run the example try:

cd libraries/examples/browser-example
mvn install
open sample.html

This should open a browser which then shows some simple HTML which then includes some dynamically generated content.

Running the sample on Java 7 with JavaFX and kool.io's browser

You can also run the sample as Java code on a JVM using JavaFX (which includes its own webkit rendering engine for HTML / CSS / JS support) using the kool.io JavaFX browser.

First you need to install Java 7 update 4 or later which ships with JavaFX.

You will need to setup JAVA_HOME and PATH environment variables to point to the latest JDK. If you install Java 7 and use a Mac you might want to run this first...

export JAVA_HOME=/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH

You can check you have JavaFX in your JDK install via

ls -l $JAVA_HOME/jre/lib/jfxrt.jar

which should find the JavaFX runtime jar (jfxrt.jar).

Running the sample in JavaFX

To run the sample try...

mvn test -Pjavafx

Assuming you've Java 7 enabled and JAVA_HOME points to the JRE/JDK for Java 7 or later which includes JavaFX.

This should popup a JVM process with an embedded webkit based browser running the application; using the compiled bytecode on the JVM rather than JavaScript.