Resolving Blade issue on Windows

Blade is one of the great Liferay development tools. This is true, unless it stops working! Or, maybe you ran the blade installer and the error came up and you now wonder what to do now?! Punt? Watch a spaghetti western? That’s what this blog is about, resolving issue(s) with blade, two issues that have occurred on Windows for me using blade.

  1. Blade Error Failed to find Java VM
  2. Liferay Server Home Setting

If you haven’t installed blade, install it! I recommend the command line install.

curl -L https://raw.githubusercontent.com/liferay/liferay-blade-cli/master/cli/installers/local | sh

Blade Error

Run blade update and suddenly your blade stops working with the following!

Blade Error message
 
c:\> cd \Users\Brian Lavender\workdirs\liferay04
C:\Users\Brian Lavender\workdirs\liferay04>blade update
Updating from: https://repository-cdn.liferay.com/nexus/content/repositories/liferay-public-snapshots/com/liferay/blade/com.liferay.blade.cli//4.0.10-SNAPSHOT/com.liferay.blade.cli-4.0.10-20211115.103749-8.jar

C:\Users\Brian Lavender\workdirs\liferay04>blade
 [err] Failed to find Java VM.

Check the JAVA_HOME Environment variable and it matches.

C:\Users\Brian Lavender\workdirs\liferay04>echo %java_home%
C:\pkg\java\jdk-11.0.12+7

Check the blade settings. Change directory to the bin folder for blade. Notice how the blade.ini has been modified.

c:\> cd C:\Users\Brian Lavender\.jpm\windows\bin
c:\> dir /o:d
11/15/2021  09:59 AM               156 blade.ini  

Add a line for vm.location. In my case, it will be vm.location=c:\pkg\java\jdk-11.0.12+7\bin\server\jvm.dll

main.class=com.liferay.blade.cli.BladeCLI
log.level=error
classpath.1=C:\Users\Brian Lavender\.jpm\windows\repo\D629B892845151CB956A362061ECF42FD3940DAA
vm.location=c:\pkg\java\jdk-11.0.12+7\bin\server\jvm.dll

Check blade that it works now

c:> blade version

Liferay Server Home Setting

You can now use blade to start the server from within your workspace. Add the following to gradle.properties in your workspace, so that blade and gradlew will find the liferay install. If you don’t have a workspace yet, create it with blade init.

liferay.workspace.home.dir=/home/brian/pkg/liferay/liferay-ce-portal-7.4.2-ga3

In the below example, my workspace is in C:\Users\Brian Lavender\workdirs\liferay04. You can run the following commands. Blade knows where your server is located using the liferay.workspace.home.dir setting. We’ll put gradlew in our path too!

c:> cd C:\Users\Brian Lavender\workdirs\liferay04
c:> set path=C:\Users\Brian Lavender\workdirs\liferay04;%path%
c:> blade server start
c:> blade server stop
c:> blade sh lb

Plus, you can also build your modules and deploy using the gradlew. Say we have foo-mvc module and we want to clean, build and deploy to our server.

c:> cd modules\foo-mvc
c:> gradlew clean build install

Conclusion

I hope these tips have helped those who may have encountered these errors and helps those who unzip Liferay into a folder and run it from there.

 

Blogs

Second correction, the workspace home dir is the following under my Windows configuration: ​​​​​​​liferay.workspace.home.dir=C:/pkg/liferay/liferay-ce-portal-7.4.2-ga3