Subject: HelloWorld.java --> HelloWorld.js
Author: Alex_Raj
In response to: pom.xml
Posted on: 04/01/2021 01:04:02 AM
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
>
> On 04/01/2021 01:02:04 AM
Alex_Raj wrote:
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-->
References: