cincheo / jsweet

A Java to JavaScript transpiler.
http://www.jsweet.org
Other
1.45k stars 160 forks source link

Can't compile quick start #441

Open blackears opened 6 years ago

blackears commented 6 years ago

I just came across JSweet, and am trying it out to see how it works. Unfortunately, I’m having trouble getting the quick start to run. I got up to step 3 on your Getting Started tutorial (http://www.jsweet.org/getting-started/) and encountered some errors. I’m building this via Powershell on a Windows 10 box.

After downloading a lot of packages from Maven, the compiler spits out the below message. It looks like something called JCTree is missing. Is this supposed to be in the JDK? I have Java 1.8.0_171 installed on my machine.

[INFO] extraSystemPath: null [INFO] ———————————————————————— [INFO] BUILD FAILURE [INFO] ———————————————————————— [INFO] Total time: 01:20 min [INFO] Finished at: 2018-06-13T11:46:07-04:00 [INFO] ———————————————————————— [ERROR] Failed to execute goal org.jsweet:jsweet-maven-plugin:2.2.0-SNAPSHOT:jsweet (generate-js) on project jsweet-quickstart: Execution generate-js of goal org.jsweet:jsweet-maven-plugin:2.2.0-SNAPSHOT:jsweet failed: A required class was missing while executing org.jsweet:jsweet-maven-plugin:2.2.0-SNAPSHOT:jsweet: com/sun/tools/javac/tree/JCTree [ERROR] —————————————————– [ERROR] realm = plugin>org.jsweet:jsweet-maven-plugin:2.2.0-SNAPSHOT [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy [ERROR] urls[0] = file:/C:/Users/kitfox/.m2/repository/org/jsweet/jsweet-maven-plugin/2.2.0-SNAPSHOT/jsweet-maven-plugin-2.2.0-SNAPSHOT.jar [ERROR] urls[1] = file:/C:/Users/kitfox/.m2/repository/javax/enterprise/cdi-api/1.0/cdi-api-1.0.jar [ERROR] urls[2] = file:/C:/Users/kitfox/.m2/repository/org/codehaus/plexus/plexus-utils/3.1.0/plexus-utils-3.1.0.jar [ERROR] urls[3] = file:/C:/Users/kitfox/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.24/plexus-interpolation-1.24.jar …

lgrignon commented 6 years ago

Hello. Which JVM are you using? (Oracle or openjdk or other?) Which version of maven?

blackears commented 6 years ago

I'm using Oracle's Java.

$ java -version java version "1.8.0_171" Java(TM) SE Runtime Environment (build 1.8.0_171-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)

$ mvn -version Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-24T14:49:05-05:00) Maven home: D:\bin\apache-maven-3.5.3\bin.. Java version: 1.8.0_171, vendor: Oracle Corporation Java home: C:\Program Files\Java\jre1.8.0_171 Default locale: en_CA, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

lgrignon commented 6 years ago

tools.jar which contains the JCTree class should be in the maven classpath. Could you please check that this is true?

blackears commented 6 years ago

Maven has a classpath? I don't see anything in the docs about that (aside from classes included within a pom file). I've not set the general classpath for my computer either. Are you saying I should set the system CLASSPATH? Also, where is this tools.jar that needs to be included?

lgrignon commented 6 years ago

It should be downloaded to your local maven repository, it is a transitive dependency of the maven plugin. https://github.com/cincheo/jsweet/blob/master/transpiler/pom.xml#L215

Have you tried adding this artifact as a dependency?

blackears commented 6 years ago

I'm not that familiar with maven and am not sure what you're talking about here. I checked the .m2 directory in my home directory, and there was no tools.jar there (although there was a tools-8.pom.lastUpdated file). I added the XML for the tools dependency you linked to above to the projects pom file and compiled again, but am still getting errors.

Here's the log of my build: buildLog.txt

lgrignon commented 6 years ago

Yeah there should be a jar in .m2\repository\com\sun\tools\8 try forcing refresh your dependencies please

blackears commented 6 years ago

I deleted my .m2\repository and tried again. Still getting the same error. tools.jar is not downloaded for some reason (ie, it's not appearing in the .m2/repository/com/sun/tools/8 directory). I'm attaching a log of my build. buildLog.txt

JimmyBHuynh commented 6 years ago

hi i have the same problem however i see a tools-8.jar in my .m2 yet it is still telling me im missing com/sun/tools/javac/tree/JCTree

lgrignon commented 6 years ago

Hello, thanks for reporting. Which JVM please? Maybe you have the same version

JimmyBHuynh commented 6 years ago

oh i figured it out so what you have to do is go to environmental variable make a new user variable called JAVA_HOME and set the value to C:\Program Files\Java\jdk1.8.0_171 silly me it builds fine now

blackears commented 6 years ago

I had my JAVA_HOME pointing to my jre. After changing that and checking out a new version of jsweet-quickstart, I was able to compile.

Jsweet doesn't seem to work with the latest Java 10 JDK, though.

lgrignon commented 6 years ago

Hello, yes JSweet was fully tested for Java 8 but not validated for Java 9 & 10 (I think it breaks with Jigsaw)

Well, thank you for solving the problem on your own, it's a shame that the JRE instead of JDK error is not properly reported to the user (I think there is a warning in the logs, but way too shy :))

Could you please create a specific issue for this? I will enhance it.

lgrignon commented 6 years ago

Or if you want to PR, contributions are all welcome

blackears commented 6 years ago

I added an issue at https://github.com/cincheo/jsweet/issues/443.

What do you mean by PR?

lgrignon commented 6 years ago

PR stands for Pull Request :)

https://help.github.com/articles/about-pull-requests/