Deployment
Our example continues with the HTML file src/main/webapp/index.html, which will include the compiled HelloWorld class and run it.
Each HTML page using compiled Jangaroo code has to include the Jangaroo Runtime. Then, you can load and start your ActionScript main class with a single JavaScript statement:
<html>
<head>
<title>Hello World - Jangaroo</title>
</head>
<body>
<script type="text/javascript"
src="scripts/jangaroo-runtime-debug.js"></script>
<script type="text/javascript">
joo.classLoader.run("HelloWorld");
</script>
</body>
</html>
Jangaroo takes care of automatically loading the scripts of all dependent classes. In a production environment, it is possible and recommended to use the library file, i.e. the concatenated version of all your compiled Jangaroo classes and include the single concatenated file after including the runtime.
Now, again on the command line, enter
mvn package
Note that the source file index.html will be copied to target/hello-world-0.1.0-SNAPSHOT during the build process. Thus, in your browser, navigate to
file:///PROJECT_HOME/target/hello-world-0.1.0-SNAPSHOT/index.html
or open the file using the corresponding browser menu, or simply use the Windows command line again:
start target/hello-world-0.1.0-SNAPSHOT/index.html
Note: Do not try to open the HTML file at its source location, but only in the target folder, or it will not find any script files!
Obviously, this example is very basic and contains a lot of overhead considering its limited functionality. However, when your JavaScript code grows along with your application requirements and your client-side logic becomes increasingly more complex, the Jangaroo tool set together with your IDE's ActionScript 3 / Flex support will help you keep your code readable, maintainable, and extensible.
Read more about the Jangaroo language features to learn how Jangaroo supports you in achieving these goals.