|
Alex_Raj member offline |
|
posts: |
99 |
joined: |
05/16/2006 |
from: |
San Jose, CA |
|
|
|
|
|
JSweet |
How to install JSweet?
Requirements: Node.js -- Globally downloaded with system parameter path C:\Program Files\nodejs\. Node.js is an open-source, cross-platform JavaScript run-time environment that executes JavaScript code outside of a browser.
From Eclipse: Go to: Help > Install New Software Press the Add… button to add:
http://eclipse-update-site.jsweet.org
|
|
|
|
|
|
|
Alex_Raj member offline |
|
posts: |
99 |
joined: |
05/16/2006 |
from: |
San Jose, CA |
|
|
|
|
|
pom.xml |
If starting from a brand new project ...
Here is the procedure: File > New > Dynamic Web Project -- Named as HelloJSweet Right click on your project: Configure > Enable JSweet builder Right click on your project: Configure > Convert to Maven Project. Leave all the default options. Edit your pom.xml to add the JSweet repository and dependency sections
<!-- repositories -->
<repositories>
<repository>
<id>jsweet-central</id>
<name>libs-release</name>
<url>http://repository.jsweet.org/artifactory/libs-release-local</url>
</repository>
<repository>
<snapshots />
<id>jsweet-snapshots</id>
<name>libs-snapshot</name>
<url>http://repository.jsweet.org/artifactory/libs-snapshot-local</url>
</repository>
</repositories>
<!-- end repositories -->
<!-- dependencies-->
<dependencies>
<dependency>
<groupId>org.jsweet</groupId>
<artifactId>jsweet-core</artifactId>
<version>6.3.0</version>
</dependency>
<dependency>
<groupId>org.jsweet.candies</groupId>
<artifactId>jquery</artifactId>
<version>1.10.0-20170726</version>
</dependency>
</dependencies>
<!-- end dependencies-->
|
|
|
|
|
|
|
Alex_Raj member offline |
|
posts: |
99 |
joined: |
05/16/2006 |
from: |
San Jose, CA |
|
|
|
|
|
HelloWorld.java --> HelloWorld.js |
Now, you can code a java file:
package org.zsp.jsweet;
import static jsweet.dom.Globals.*;
import jsweet.dom.HTMLElement;
public class HelloWorld {
public static void main(String[] args) {
alert("This example writes 'Hello world' in the document!");
HTMLElement e = document.getElementById("target");
e.innerHTML = "Hello world!";
}
}
If everything goes smoothly, you should find a JWseet generated JS file here:
/js/org/zsp/jsweet/HelloWorld.js
Note: js is the default folder which can be configured via Window > Preferences > JSweet > Generated javascript folder
|
|
|
|
|
|
|
Alex_Raj member offline |
|
posts: |
99 |
joined: |
05/16/2006 |
from: |
San Jose, CA |
|
|
|
|
|
index.html |
Here is the corresponding HTML file index.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello world</title>
</head>
<body>
<div id="target"></div>
<script src="./js/org/zsp/jsweet/HelloWorld.js"></script>
</body>
</html>
|
|
|
|
|
|
|
Alex_Raj member offline |
|
posts: |
99 |
joined: |
05/16/2006 |
from: |
San Jose, CA |
|
|
|
|
|
pom.xml |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>HelloJSweet</groupId>
<artifactId>HelloJSweet</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<!-- repositories -->
<repositories>
<repository>
<id>jsweet-central</id>
<name>libs-release</name>
<url>http://repository.jsweet.org/artifactory/libs-release-local</url>
</repository>
<repository>
<snapshots />
<id>jsweet-snapshots</id>
<name>libs-snapshot</name>
<url>http://repository.jsweet.org/artifactory/libs-snapshot-local</url>
</repository>
</repositories>
<!-- end repositories -->
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
</plugins>
</build>
<!-- dependencies-->
<dependencies>
<dependency>
<groupId>org.jsweet</groupId>
<artifactId>jsweet-core</artifactId>
<version>6.3.0</version>
</dependency>
<dependency>
<groupId>org.jsweet.candies</groupId>
<artifactId>jquery</artifactId>
<version>1.10.0-20170726</version>
</dependency>
</dependencies>
<!-- end dependencies-->
</project>
|
|
|
|
|
|
|
Alex_Raj member offline |
|
posts: |
99 |
joined: |
05/16/2006 |
from: |
San Jose, CA |
|
|
|
|
|
Eclipse version |
JSweet compliant Eclipse versions:
jee-mars-2 (2016) jee-2019-09 jee-2020-06
|
|
|
|
|
|
|