As a developer in need of several Java jdk's (or at least the latest LTS), I need a different approach. Firstly, you need to know that Anystudio only works with jdk8 (pre-installed), or jdk11 (configurable). You can forget about the rest. Secondly, being a derivative from Eclipse, your JAVA_HOME needs to point towards the correct jdk or you'll get the afformentioned error where the 61 means the user had jdk17 configured.
STEPS TO CONFIGURE JDK 11 (for Anypoint v7.14.0)
- right click on your project
- go to "Run As" and select "Mule Application (configure). A new window opens.
- In that window you'll see multiple tabs. Select "JRE"
- Choose "Alternate JRE" and click on the "Installed JRE's" button. A new window opens
- In that window you'll see an "Add..." button. Select "Standard VM", click "Next >"
- Choose your jdk directory. Click "Finish" and select your jdk from the dropdown.
Alternatively:
- locate your AnypointStudio.ini file and configure your -vm option described here, or in code:
-vm
C:\Program Files\Java\jdk-11.0.4\bin\javaw.exe
There are a few alternatives when configuring the Anystudio.ini file, so if the change above doesn't work, search the Mule forums for the latest info on Configure studio to use your own jdk.
- Go to your configuration and choose "Execution environment" instead of Alternate JRE. Though make sure that it points to CDC-1.0/Foundation-1.0 (your_jdk_version)
This should work when your JAVA_HOME points to the correct jdk. If, like me, you need to switch to other versions, it can be bothersome to constantly change it manually. For this, I created .bat-files which I execute before starting up Anystudio. Make sure that your computer's path references JAVA_HOME instead of a hardcoded path. Otherwise the steps below won't be enough.
CREATING .BAT-FILES TO PROGRAMMATICLY CHANGE YOUR JAVA_HOME (for Windows 11)
- Open notepad
- type the following, keeping in mind to change the jdk to your personal path/version:
setx /M JAVA_HOME "C:\Program Files\Java\jdk-11.0.4"
- Save file with your_file_name.bat as "All files"
- Create a shortcut from your bat-file
- Right-mouse click on the shortcut and go to "Properties". A new window opens
- In the window that opened, go to "Advanced"
- Select "Run as administrator", click "Ok", click "Apply"
Keep in mind, you'll need 2 of those .bat-files. One for downgrading your JAVA_HOME (execute before opening Anystudio) and one for restoring it (execute it after you're done working in Anystudio). Both system settings and commandlines don't show a changed JAVA_HOME path directly. close/reopen them to see that the changes have been applied.