Chapter 11. Getting started with Java2Script sources

 

"What is happiness? The feeling that power is growing, that resistance is overcome."

 Friedrich Nietzsche
Table of Contents
Getting Java2Script sources
Source organization
Building the sources
Running and debugging
Exporting the plugin
How to Extend the Java2Script compiler

Getting Java2Script sources

This section is for those developers who want to install Java2Script sources, run the plugin in Eclipse plugins sdk for testing, see how J2S works, be able to change it, fix it, redistribute it with your own modifications, etc

We will use Eclipse 3.6. You should choose an Eclipse distribution that supports for Eclipse plugin development (almost all).

Install Eclipse 3.6 and Java2Script plugin

We will need Eclipse 3.6 with the Java2Script plugin installed in order to build sources. [1]

If you already have Eclipse 3.6 installed and are comfortable doing your Java programming there, you can use it. If not, download an Eclipse 3.6 distribution oriented to Java and Eclipse plugin development, like Eclipse 3.6 Classic. Also download Java2Script plugin for Eclipse 3.6 from Java2Script homepage

As explained in previous sections, installing Java2Script plugin is easy: just extract files and overwrite the plugins Eclipse folder content and restart Eclipse.

Once Eclipse has been restarted, you can verify whether Java2Script plugin is successfully installed or not by going to

Install SVN support

If you are a developer you probably already has SVN support in your Eclipse. If not, this section will explain how you can easily install subclipse using Eclipse marketplace.

Check if you have the Help->Eclipse Marketplace menu item. If so please go to the next paragraph. If not, we will first need to install the Eclipse marketplace client. It is easy, just go to menu Help->Install new Software... In the dialog, enter "Work with" Helios - http://download.eclipse.org/releases/helios, wait a moment to Eclipse to download the available software catalog and then search the work "marketplace" as shown in the following figure. Check "Marketplace Client", follow the steps and wait until Eclipse marketplace client is downloaded and installed:

Figure 11-1. Installing Eclipse Marketplace client

At this point you should have Eclipse marketplace client support in your Eclipse installation. So, we will install subclipse plugin for SVN team support. Goto Help->Eclipse Marketplace, choose "Eclipse marketplace" and press Next

Figure 11-2. Open Eclipse Marketplace

Click on next and search "subclipse" and then click on "install" button:

Figure 11-3. search for subclipse

TODO At last, we must restart Eclipse to apply the changes.

Import Java2Script sources

Now that we have SVN support in our Eclipse, we can check out Java2Script source code. Go to File->Import...->SVN->Checkout projects from SVN.

Figure 11-4. Import sources from SVN repository

Select "Create a new Repository location", click in "next" and enter https://java2script.googlecode.com/svn/trunk/ [2]. Clicking on next will load all folders of the project Java2Script. Expand folder "sources", and select all its child folders except net.sf.j2s.core and net.sf.j2s.ui:

Figure 11-5. Import sources from SVN repository

Click on finnish for start checking out Java2Script project sources.

Because we want to support for Eclipse 3.6 we have to obtain the sources of net.sf.j2s.core and net.sf.j2s.ui from another location: https://java2script.googlecode.com/svn/branches. So we repeat the process for that repository location, selecting net.sf.j2s.core_3.6 and net.sf.j2s.ui_3.6 folders:

Figure 11-6. Import sources from SVN repository

After this, the lastest codes are checked out. You shoud see all Java2Script related projects in your Eclipse workspace :

Figure 11-7. Import sources from SVN repository

Note: For commiting your changes back to java2script sources you need to be a member of the developer team. Just ask in Java2Script user group. Otherway, if you only want to checkout the sources, you don't need to use https:// just http://.

Notes

[1]

Yes, Java2Script sources are compiled using the Java2Script compiler! For example, many .java files, like java.lang, java.util, org.eclipse.swt, etc need to be compiled to JavaScript in order to build the j2slib JavaScript library which all Java2Script web applications are based on.

[2]

We take this url from Java2Script googlecode site.