go to  ForumEasy.com   
JavaPro  
 
 
   Home  |  MyForum  |  FAQ  |  Archive    You are not logged in. [Login] or [Register]  
Forum Home » JavaScript » JSweet
Email To Friend  |   Set Alert To This Topic Rewarding Points Availabe: 0 (What's this) New Topic  |   Post Reply
Author Topic: JSweet
Alex_Raj
member
offline   
 
posts: 99
joined: 05/16/2006
from: San Jose, CA
  posted on: 04/01/2021 01:00:04 AM    Edit  |   Quote  |   Report 
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
    

     Profile | Reply Points Earned: 0
    Alex_Raj
    member
    offline   
     
    posts: 99
    joined: 05/16/2006
    from: San Jose, CA
      posted on: 04/01/2021 01:02:04 AM    Edit  |   Quote  |   Report 
    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-->
    


  •  Profile | Reply Points Earned: 0
    Alex_Raj
    member
    offline   
     
    posts: 99
    joined: 05/16/2006
    from: San Jose, CA
      posted on: 04/01/2021 01:04:02 AM    Edit  |   Quote  |   Report 
    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

     Profile | Reply Points Earned: 0
    Alex_Raj
    member
    offline   
     
    posts: 99
    joined: 05/16/2006
    from: San Jose, CA
      posted on: 04/01/2021 01:08:06 AM    Edit  |   Quote  |   Report 
    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>
    

     Profile | Reply Points Earned: 0
    Alex_Raj
    member
    offline   
     
    posts: 99
    joined: 05/16/2006
    from: San Jose, CA
      posted on: 07/27/2023 07:33:01 AM    Edit  |   Quote  |   Report 
    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>
    
     Profile | Reply Points Earned: 0
    Alex_Raj
    member
    offline   
     
    posts: 99
    joined: 05/16/2006
    from: San Jose, CA
      posted on: 07/30/2023 06:07:21 AM    Edit  |   Quote  |   Report 
    Eclipse version
    JSweet compliant Eclipse versions:


    jee-mars-2 (2016)
    jee-2019-09
    jee-2020-06


     Profile | Reply Points Earned: 0

     
    Powered by ForumEasy © 2003-2005, All Rights Reserved. | Privacy Policy | Terms of Use
     
    Get your own forum today. It's easy and free.