Skip to main content
Acui.1
Visitor II
December 22, 2019
Question

STM32CubeProgrammer execute fail with Could not find or load main class com.st.app.Main

  • December 22, 2019
  • 9 replies
  • 7857 views

Hi all, I'm new to STM32 and I encountered with an error when I run STM32CubeProgrammer after installing the tool on Ubuntu 18.04 according to STM UM2237 user manual

the error is : Could not find or load main class com.st.app.Main.

I googled and it was said that it might be the CLASSPATH config problem which leads to the class cannot be found. But I searched the install path which is /home/mypath/STMicroelectronics/STM32Cube/ and cannot find any JAVA class looks like this main class(only 3 JAR file found: uninstaller.jar, OpenJFXWarning.jar and STLinkUpgrade.jar), and I even don't know which path to add to CLASSPATH.

Does anyone have ideas about why this happened and how to fix it, thanks in advance.

This topic has been closed for replies.

9 replies

LBonv.1
Visitor II
April 13, 2020

Same Issue here on MacOS 10.15.4 .

I tried with multiple jdk installed with homebrew and controlled with jenv

openjdk version "14" 2020-03-17

OpenJDK Runtime Environment (build 14+36-1461)

OpenJDK 64-Bit Server VM (build 14+36-1461, mixed mode, sharing)

openjdk version "1.8.0_242"

OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_242-b08)

OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.242-b08, mixed mode)

22:07 $ brew cu

==> Options

Include auto-update (-a): false

Include latest (-f): false

==> Updating Homebrew

Updated 1 tap (homebrew/cask).

==> Updated Casks

openttd

==> Finding outdated apps

    Cask        Current                Latest                A/U  Result

 1/29 adoptopenjdk8    8,242:b08               8,242:b08                 [  OK  ]

8/29 java        14,36:076bab302c7b4508975440c56f6... 14,36:076bab302c7b4508975440c56f6...    [  OK  ]

OStor.7
Visitor II
April 16, 2020

Hi, @Acui.1​ and @LBonv.1​ 

I've encountered the same issue on Linux Manjaro (or Arch). I've had Java 13 installed '$java -version'.

Eventually after some googling, in the official STM Document RN0109, I found out that only Java version 8 (1.8.0+) is supported. I started installing all other different Java versions from AUR. Of course, none of them worked and '$java -version' still told me that it was version 13.

After this I wiped everything connected with java (jdk) from Package Manager (probably unnecessary step!). And tried installing again one of them from AUR. That didn't help either. The error changed however.

The first error was:

Error: Could not find or load main class com.st.app.Main

Caused by: java.lang.NoClassDefFoundError: javafx/application/Application

Then it changed to just:

Error: Could not find or load main class application.Main

Then from Arch wiki I found out that there are different Java packages JRE and JDK. Previously I've tried to install JDK and this was my mistake.

Java runtime environment - needed for executing Java GUI programs.

Java Development Kit - needed for Java development.

https://wiki.archlinux.org/index.php/Java#OpenJDK

After installing Full OpenJRE 8 with java8-openjfx (this is important), STM32CubeProgrammer launched successfully, no restart was needed.

In conclusion

So, at first, I suggest you checking what Java version is installed:

$java -version

Then, if it's not version 8, try to install Full JRE 8 (jre8-openjdk) with java8-openjfx included and check how it goes.

DGunn.1
Visitor II
April 30, 2020

I am having the same issue on Ubuntu 18.04 LTS. I have OpenJRE 8 installed and openjfx.

$Java -version

openjdk version "1.8.0_252"

OpenJDK Runtime Environment (build 1.8.0_252-8u252-b09-1~18.04-b09)

OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)

$ STM32CubeProgrammer

Error: Could not find or load main class com.st.app.Main

$

This seems to have been an issue for a long time in the install process of STM32CubeProgrammer. There seems to be something missing in the documentation since this problem happens to a lot of people. There is no mention of installing packages in the instructions:

https://wiki.st.com/stm32mpu/wiki/Getting_started/STM32MP1_boards/STM32MP157C-DK2/Let%27s_start/Populate_the_target_and_boot_the_image

I am trying to use my MP157C-DK2 but I am stuck at getting the tools to run...

DGunn.1
Visitor II
April 30, 2020

update!

I found another post:

https://community.st.com/s/question/0D50X0000BVoSLH/i-am-not-able-to-start-stm32cubeprogrammer-even-installed-oracle-jdk-1301-and-openjfx-whats-the-problem

The instructions there worked. Specifically the section about changing the version of openjfx:

=> sudo apt purge openjfx

=> sudo apt install openjfx=8u161-b12-1ubuntu2 libopenjfx-jni=8u161-b12-1ubuntu2 libopenjfx-java=8u161-b12-1ubuntu2

=> sudo apt-mark hold openjfx libopenjfx-jni libopenjfx-java

Could the installation instructions please be updated to include this? this would save everyone a lot of time and hunting.

Daniel Glasser_2
Associate II
May 16, 2020

Note: This does not work on Ubuntu 20.04; the JDK8 compatible version of openjfx is not available for Focal Fossa, it seems. I wasn't able to get this to work in Ubuntu 19.10 either. I have a very nice development board and I've yet to be able to load the starter package on it after many months of trying on and off.

I would try it under Windows (second choice), but I've not found directions for setting things up from there.

Java continues to deliver on its "write once, run anywhere" promise by once again not being backward compatible with programs compiled for prior releases.

RSacc.1
Graduate
May 5, 2020

Thanks this worked for me after god knows how many attempts!

WAKE UP ST MICRO ! Developers most of them are using LINUX !

GEt to work !

My word this is just unacceptable these issues have been here for more than 2 years !

ALavr.1
Visitor II
May 8, 2020

Same issue on MacOS

RSacc.1
Graduate
May 8, 2020

Ok so because ST micro developers, paid full time and quite well as I understand, cannot be bothered updating their software to work with the latest versions of Java and JavaFx, here is what worked for me, open source style do it yourself ! ;)

The answer is pretty much in the replies above but not quite in my case.

managed to install the openjdk jre 8.

Note: ensure that your JAVA_HOME var is set up to point to it at all times between installation and running the st flasher.

But this is not enough. I had 2 errors the firdt being about openjfx not being found, and then some st.com.something class not being found. The forst is related to openjfx-java the later to the version of the jre that needs to be openjre 8-252 or 251.​

I tried installing openjfx or libopenjfx as recommended, using the version tag or none i.e.

Using tag ​8u161-b12-1ubuntu2

Openjfx=​8u161-b12-1ubuntu2

Or without it

Apt install openjfx

Did not work.

You need to ​Install exactly openjfx-java as well.

Which was not mentioned here but on another link i googled.

Try installing it without the tag and then with the tag ​8u161-b12-1ubuntu2 if the first does not work.

As you will install the right jre and then the right jfx the error messages will disappear one by one in my case.

All in all it took me ​10days on and off trying different things and overall I'd say close to 8hours.

Shame on the ST dev team that's in charge of this mess!​ It's certainly an easy fix for them but it needs to be done. There's no excuses at this stage!

MTorr.3
Visitor II
July 2, 2020

They could always do like they did with STM32CubeMonitor-RF and provide a bundled jre8 with all of their dependencies. That would be nice...

https://docs.oracle.com/javase/8/docs/technotes/guides/deploy/self-contained-packaging.html

MTorr.3
Visitor II
July 2, 2020

Curiously enough, after installing the Oracle JRE8 I get a popup message with:

```

CubeProgrammer_API or one of its dependencies is missing. Please try

reinstalling the program or check your java architecture.

​```

However, if I try to reinstall using the Oracle JRE8 it fails, complaining of a non existing file (it looks like the installer is trying to`chmod` a file before copying it).

So there's that, can't upgrade the stm32wb55 with the provided software.

Here's an alternative:

https://github.com/stlink-org/stlink

Most Linux distributions with a package manager should have that with the names:

  • libstlink1
  • stlink-gui
  • stlink-tools

if not you can build it from source.

Cheers!

FLACO.1
Associate
October 3, 2020

Hi,

To make it work with the bundled openjfx package, you may edit the bin/STM32CubeProgrammer and add your openjfx path and modules :

java --module-path /usr/share/openjfx/lib --add-modules javafx.controls,javafx.fxml,javafx.web -jar $DIR/STM32CubeProgrammerLauncher

FBusy.1
Visitor II
October 12, 2020

I used openjfx-15 solved this problem,download openjfx-15_linux-x64_bin-sdk.zip from https://openjfx.io/​, unzip to somewhere(such as :/usr/opt/),then modify the program startup file(${Program installation directory}/bin/STM32CubeProgrammer),may need sudo ,replace the last line "java -jar $DIR/STM32CubeProgrammerLauncher" with "java --module-path /usr/opt/javafx-sdk-15/lib --add-modules=javafx.base --add-modules=javafx.fxml --add-modules=javafx.graphics --add-modules=javafx.media --add-modules=javafx.swing --add-modules=javafx.web --add-modules=javafx.controls -jar $DIR/STM32CubeProgrammerLauncher", "/usr/opt/javafx-sdk-15/lib" is your openjfx's path, and my javasdk is jdk11, I also tried jdk12, also worked well.

FM.1
Associate
April 28, 2023

On Ubuntu 22.04, installed using default paths (version 1.1.1). Then define this in ~/.bashrc

alias stm32-monitor-power='$HOME/STMicroelectronics/STM32CubeMonitor-Power/jre/bin/java -jar $HOME/STMicroelectronics/STM32CubeMonitor-Power/STM32CubeMonitor-Power.jar'

To start use:

stm32-monitor-power