Java2Script User's Guide

Sebastián Gurin

Java2Script

This document is for Java programmers who want to start programming its web applications in Java language using Java to JavaScript compiler Java2Script .


Table of Contents
1. About this document
2. Introduction
What is Java2Script?
Demonstrations
Comparing Java2Script to other similar technologies
3. Getting Started
A simple Java2Script application
Configuring your Java2Script application launcher.
4. The J2S plugin
Java2Script project
J2S Java to JavaScript compiler
Compiler configuration
Application launching
Using templates
Debugging
JavaScript ClassLoader and Hotspot
Libraries in Java2Script
Command line API
5. Java Support
Using unsupported java classes
JRE Emulation Reference
Package java.lang
Package java.lang.annotation
Package java.lang.reflect
Package java.io
Package java.util
Package java.util
6. Integrated Java libraries
Java2Script SWT
Java2Script AJAX
7. Customizing output code with @j2s JavaDoc tags and annotations
Using @j2s tags in JavaDoc
Writing native JavaScript code with @j2sNative
Using real Java annotations instead JavaDoc for @j2s
8. Code Translation
Generated JavaScript files
Doing java in HTML documents
Types
Exceptions
9. Working With native code
Native Objects
Accessing native JavaScript objects from Java
Native objects mode support
JavaScript functions
10. Client - Server communication
ajax
Simple RPC
Simple pipe / commet
11. Getting started with Java2Script sources
Getting Java2Script sources
Install Eclipse 3.6 and Java2Script plugin
Install SVN support
Import Java2Script sources
Source organization
net.sf.j2s.core
net.sf.j2s.java.core
net.sf.j2s.java.org.eclipse.swt
net.sf.j2s.lib
Building the sources
Running and debugging
Exporting the plugin
How to Extend the Java2Script compiler
Creating a Java2Script compiler extension eclipse plugin
Other example: html attributes with javadoc annotations
A. J2S Java Emulation API
Java Language Emulation API
Java Runtime Emulation API
B. GNU Free Documentation License
List of Figures
2-1. Comparing Java2Script and Java JDK roles
2-2. Java2Script architecture diagram
3-1. Creating a new Java2Script application project
3-2. Launch a Java2Script application
3-3. Launch a Java2Script application - the J2S Console view
3-4. Launch a Java2Script application - the J2S Console view
3-5. Launch a Java2Script application - the J2S Console view
3-6. Launch a Java2Script application - the J2S Console view
4-1. Debug As... Java2Script application context menu
4-2. HotSpot debugging the application - first screenshot
4-3. HotSpot debugging the application - application change notification
4-4. HotSpot debugging the application - changes were applied
7-1. @j2s annotations eclipse auto completion menu
8-1. Concepts from both languages and what J2S takes from both worlds
8-2. A clean J2S Application launcher configuration
11-1. Installing Eclipse Marketplace client
11-2. Open Eclipse Marketplace
11-3. search for subclipse
11-4. Import sources from SVN repository
11-5. Import sources from SVN repository
11-6. Import sources from SVN repository
11-7. Import sources from SVN repository
11-8. Running the Java2Script Eclipse plugin
11-9. Packing j2slib
11-10. Running the Java2Script Eclipse plugin
11-11. A breakpoint in some Java to JavaScript compiler class:
11-12. Creating a new plugin eclipse project
11-13. Giving a name to the plugin
11-14. new eclipse plugin project last step
11-15. eclipse plugin dependencies tab.
11-16. eclipse outline view showing some java elements of a compilation unit
11-17. eclipse plugin - adding extension point
11-18. eclipse plugin - setting extension point name
11-19. eclipse plugin - creating extension point class