Message Boards

Exercise: Create a Liferay Module, Error "Could not create output jar"

Noah Bowman, modified 3 Years ago.

Exercise: Create a Liferay Module, Error "Could not create output jar"

New Member Posts: 13 Join Date: 9/28/20 Recent Posts

I'm posting this here because I was unable to find a post anywhere else that gave clear direction on how to fix this issue in the backend developer training. While following the steps for this exercise, I ran into this error while trying to deploy the "training-portlet" module to a local Liferay TomCat server.

 

 

 

If like me you ran initBundle for Gradle, received no errors, but see this error on the portlet's deployment, then the following should work for you.

After a little more digging, I was able to figure out this error still had to do with Gradle; specifically, the jar tasks. If you navigate to the Gradle Tasks menu in the IDE and expand the build folder, you will find the jar task(s). Double-click this task and watch the console. If you get the following error, then this is the source of your portlet's failure to deploy.

 

 

You may notice that the filepath points to the JRE instead of the needed JDK. My understanding is this will happen regardless of whether your JAVA_HOME variable points to the JDK because Gradle uses a different property java.home to point to the JDK.

So how do you change this? There are a couple of ways: 1.) you can add a line to directly set the java.home property in the gradle.properties file, or 2.) you can update it through the Gradle settings in eclipse.

I chose to do it through the Gradle settings in eclipse by navigating to Window > Preferences > Gradle and setting the Java home option to the JDK filepath on my machine (ex. C:\Program Files\Java\jdk1.8.0_251).

 

I hope this helps anyone who ran into this same problem. The errors are vague, so I wanted to post this here for other beginners who may have also been unsure about where to look.

 

Noah Bowman, modified 3 Years ago.

RE: Exercise: Create a Liferay Module, Error "Could not create output jar" (Answer)

New Member Posts: 13 Join Date: 9/28/20 Recent Posts

To summarize:

  1. Make sure JAVA_HOME on environment variables is pointing to the JDK folder (not JRE, JRE_HOME should point to JRE)
  2. Under Gradle Tasks, expand the build folder
  3. Find "jar" and select "Run Gradle Tasks"
  4. If there is an error Could not find tools.jar, navigate to Window > Preferences > Gradle
  5. Under the "Advanced Options" section, set the "Java home" option to the location of your JDK folder (same as JAVA_HOME in step 1)