java2script

Java2Script: Bridge of RCP to RIA

Reusing Java codes and tools into JavaScript

Setup Java2Script Environment from Subversion Repository

Basic steps

  1. Install Eclipse 3.1/3.2/3.3/3.4/3.5/3.6, and installl Subclipse or install Subversive
  2. Checkout sources from SVN http://java2script.googlecode.com/svn/trunk/sources
    • net.sf.j2s.ajax
    • net.sf.j2s.core (For Eclipse 3.2/3.3/3.4/3.6, please checkout from http://java2script.googlecode.com/svn/branches)
    • net.sf.j2s.lib
    • net.sf.j2s.ui (For Eclipse 3.2/3.3/3.4/3.6, please checkout from http://java2script.googlecode.com/svn/branches)
  3. Unzip net.sf.j2s.lib/j2slib.zip
    If you know about ANT build script, run net.sf.j2s.lib/build/build.xml inside Eclipse, choosing target "j2s.unzip".
    If you are not familiar with ANT, you can use your familiar unzip tools, like 7-zip, or winzip to unzip j2slib.zip outside Eclipse. And then refresh project net.sf.j2s.lib.
  4. Export the above 4 projects as "Deployable plug-ins and fragments" into your current %ECLIPSE_HOME% directory. For example, you may select C:\eclipse as the directory of export destination. Project "net.sf.j2s.ajax" and "net.sf.j2s.lib" must be exported with "Package plug-ins as individual Jar archives" UNCHECKED. And project "net.sf.j2s.ajax" should be exported with "Include source code" option CHECKED, so later you can bind sources much easily.

    Attention: As now Java2Script supports Simple RPC, it requires JAVAX_SERVLET classpath variable to build project net.sf.j2s.ajax. You can create such a classpath variable pointing to Tomcat 5.0+'s servlet-apis.jar or plugin org.eclipse.tomcat's servlets.jar or other similar jar.

    (Eclipse 3.3 users should not have this problem, just ignore this.) Trying to export this plugin will fail because there are no dependency for JAVAX_SERVLET in the plugin dependencies. In order to export correct plugin, follow the instructions here:
    1. Export as plugin with sources, ignore the errors
    2. Select source folder ajaxrpc and export it as Jar into the previous plugin location, replacing older ajaxrpc.jar

    If you have installed Java2Script 1.0.0 M2 or earlier, please delete old "net.sf.j2s.*" plugins. If you enhanced JDT core jar, please replace the enhanced JDT core jar with original one which is backuped in %ECLIPSE_HOME%.
  5. Restart the Eclipse using extra "-clean" argument. Like
    eclipse -clean
    you should find the above 4 "net.sf.j2s.*" plugins list in the "Plug-in Details" (Help->About Eclipse SDK->Plug-in Details).
  6. Now you have your Java2Script development environment! Follow the Getting Started Tutorials for your tour of Java2Script world!

More advanced steps for building totally from sources

  1. Check out more sources projects
    • net.sf.j2s.java.core
    • net.sf.j2s.java.junit
    • net.sf.j2s.java.org.eclipse.swt
    • net.sf.j2s.java.org.eclipse.swt.laf
    You may have to be patient for the workspace to build these projects for the first time. (If you are just modifying part of codes or update from SVN, the building process will be much quick and accepatble.)
  2. Clean and rebuild project net.sf.j2s.ajax (net.sf.j2s.ajax is a Java2Script project but was marked as built before Java2Script plugin is installed. So a clean and rebuild process is needed).
  3. Run Ant Build Script net.sf.j2s.lib/build/build.xml. It will pack all the things required. You can choose "j2s.zip" for building the above j2slib.zip.
  4. If you want to build with Java2Script feature and update site, you should also checkout projects
    • net.sf.j2s
    • net.sf.j2s.update.site

Tests from SVN http://java2script.googlecode.com/svn/trunk/tests

  1. You can checkout the project "org.eclipse.swt.snippets" or other projects.
    Though the SWT APIs are already declared in the project "net.sf.j2s.java.org.eclipse.swt", lots of the APIs are not implmented, you may get errors while running some snippets. For example, you can select Snippet1, Snippet176, Snippet172, Snippet109, and others (you may have the joy to find out which snippets works).
  2. Current tests list
    • net.sf.j2s.test.junit
    • net.sf.j2s.test.swt
    • org.eclipse.swt.examples
    • org.eclipse.swt.snippets

Java2Script