cancel
Showing results for 
Search instead for 
Did you mean: 

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

Acui.1
Associate

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.

18 REPLIES 18
LBonv.1
Associate

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
Associate

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
Associate

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...

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.

RSacc.1
Associate II

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 !

Same issue on MacOS

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!

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.

I figured out how to use the installation on Windows for the programmer and have the demo running, however I need to download and install a version of Ubuntu where the prerequisites for the SDK are available; it seems that for now the SDK is not easily installed on Ubuntu 20.04, and I'm not sure about anything after roughly Ubuntu 16.04LTS.

STMicro should put a priority on updating the SDK to run on the most recent LTS distribution; it's just once every other year, after all. Not being a Java developer these days, I can't be sure just how difficult that is, but if they want these very interesting and capable SoCs to find their way into compelling applications, the tools are very important.