Eclipse: exception on Run As Java Application

881 views
Skip to first unread message

Jan

unread,
Apr 12, 2023, 9:08:36 AM4/12/23
to OpenPnP
Hi All!
Today I tried to build OpenPnp on a new computer and followed the guide
at https://github.com/openpnp/openpnp/wiki/Getting-Started-with-Eclipse.
Between steps 15 (Right click Main.java and from the menu select Run As
-> Java Application.) and 16 (After a few seconds OpenPnP will start.)
I'm greeted with the following exception:

Exception in thread "main"
java.lang.reflect.InaccessibleObjectException: Unable to make protected
final java.lang.Class
java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
throws java.lang.ClassFormatError accessible: module java.base does not
"opens java.lang" to unnamed module @612fc6eb
at
java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at
java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at
java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
at
javassist.util.proxy.SecurityActions.setAccessible(SecurityActions.java:159)
at
javassist.util.proxy.DefineClassHelper$JavaOther.defineClass(DefineClassHelper.java:213)
at
javassist.util.proxy.DefineClassHelper$Java11.defineClass(DefineClassHelper.java:52)
at
javassist.util.proxy.DefineClassHelper.toClass(DefineClassHelper.java:260)
at javassist.ClassPool.toClass(ClassPool.java:1240)
at javassist.ClassPool.toClass(ClassPool.java:1098)
at javassist.ClassPool.toClass(ClassPool.java:1056)
at javassist.CtClass.toClass(CtClass.java:1298)
at org.openpnp.Main.monkeyPatchBeansBinding(Main.java:112)
at org.openpnp.Main.main(Main.java:132)

Can anyone please shine a light how to resolve that?
My Eclipse version is 2023-03 (4.27.0) and I tried the
modification/workaround Mark mentioned at
https://groups.google.com/g/openpnp/c/3dv0B3Me9uw/m/HloqU8kkBQAJ. Thank You!

Jan

Jan

unread,
Apr 13, 2023, 5:02:42 AM4/13/23
to ope...@googlegroups.com
Hi All!
It seems, that this problem is related to the jre/jdk version, that
installs with the current Eclipse installer. It offers 17.0.6 as default
(which is to my understanding known to not work yet), 18 and 19. I
manually installed OpenJDK version 8 by OpenLogic
(https://www.openlogic.com/openjdk-downloads?field_java_parent_version_target_id=416&field_operating_system_target_id=All&field_architecture_target_id=All&field_java_package_target_id=All)
(installed the downloaded JDK, in Eclips Window -> Preferences -> Java
-> Installed JREs -> Add... -> Standard VM -> Directory... selected the
path to the data installed by OpenJDK and selected the new entry. Then
selected the new version under Execution Environment -> JavaSE-1.8)
How OpenPnP seems to at least try to start but throws the following
exception:

2023-04-13 10:57:58.720 SystemLogger ERROR: Exception in thread "main"
java.lang.ExceptionInInitializerError

2023-04-13 10:57:58.722 SystemLogger ERROR: at
org.openpnp.gui.components.ThemeSettingsPanel.initComponents(ThemeSettingsPanel.java:126)

2023-04-13 10:57:58.722 SystemLogger ERROR: at
org.openpnp.gui.components.ThemeSettingsPanel.<init>(ThemeSettingsPanel.java:117)

2023-04-13 10:57:58.722 SystemLogger ERROR: at
org.openpnp.Main.main(Main.java:166)

2023-04-13 10:57:58.722 SystemLogger ERROR: Caused by:
java.util.MissingResourceException: Can't find bundle for base name
org.openpnp.translations, locale en_US

2023-04-13 10:57:58.722 SystemLogger ERROR: at
java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1581)

2023-04-13 10:57:58.724 SystemLogger ERROR: at
java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1396)

2023-04-13 10:57:58.724 SystemLogger ERROR: at
java.util.ResourceBundle.getBundle(ResourceBundle.java:824)

2023-04-13 10:57:58.724 SystemLogger ERROR: at
org.openpnp.Translations.<clinit>(Translations.java:12)

2023-04-13 10:57:58.724 SystemLogger ERROR: ... 3 more

Any thoughts on that?
Is it still the wrong jre/jdk? What's the recommended version and which
version do you use?

Jan

Niclas Hedhman

unread,
Apr 13, 2023, 7:19:30 AM4/13/23
to ope...@googlegroups.com

Also see thread started by Mark; "Eclipse Developers - Problems with
Java Modules"

So, I think that Java 11 and 14 still allow (and defaults to) "legacy
mode". It is probably possible to make it run in Java 17, by fiddling
with commandline arguments to "amend" the module system, and there are
possibly articles/videos that discusses this.

Niclas

mark maker

unread,
Apr 13, 2023, 9:45:49 AM4/13/23
to ope...@googlegroups.com

Hi all,

On the test branch Jason lately switched to newer Java JDK versions 11, 17, 19. The new install4j installer now packs Java 17 (formerly 8). Older version are no longer supported (I think).

Obviously this is great progress, but as always, some issues are to be expected:

https://github.com/openpnp/openpnp/pull/1534

As Niclas already mentioned, there are some Java Module issues with Eclipse:

https://groups.google.com/g/openpnp/c/3dv0B3Me9uw/m/HloqU8kkBQAJ

As far as I know, this is actually unrelated to the Java version changes, but this recent initiative also includes bumping a new build of openpnp-capture, the underlying C++ lib for OpenPnpCaptureCamera, solving some platform stuff. I think that includes Mac OS Apple silicon support, Raspi 4, and some other PRs that were pending...

https://github.com/openpnp/openpnp-capture-java/pull/8

There too, some issues are cropping up. For instance, I can't currently run on Windows:

https://github.com/openpnp/openpnp/issues/1538#issuecomment-1502844207

I think I found the bug:

https://github.com/openpnp/openpnp-capture/pull/65

But don't know how to deploy this "into" Java JNI. Plus the CI actually fails:

https://ci.appveyor.com/project/vonnieda/openpnp-capture/builds/46764875

I hope, Jason can have a look soon! 😎

_Mark

Jan

unread,
Apr 17, 2023, 5:31:05 AM4/17/23
to ope...@googlegroups.com
Hi All!
I dug a little bit deeper into the topic and here is what I found:
- My major issue is that I don't see/understand which jre/jdk version is
required and which version is actually used. the Eclipse installer I
downloaded a few days before (rev 2023-03 4.27.0) suggests to install
jre 17.0.6. It also provides version 18 and 19. After installation (with
default settings) the only working jre version is 17.
- In Eclipse one can open project properties and there the "Java
Compiler" entry contains a line "Compiler compliance level:" with a drop
down list that says "11". With the default installation of JRE 17 there
is a small warning at the end of the page that says "When selecting 11
compliance, make sure to have a compatible JRE installed and activated
(currently 17)." Links to the related configuration dialogs follow.
There its not obvious to me how to install and activate the required JRE.
- With the information from the compiler compliance level I searched for
external JREs and after installing it, I was able to build the code.
(that was using the test branch from last week before PR #1544 where
Jason fixed OpenPnPCapture)
- Today I pulled the latest changed from April 15th of test branch and
was able to build it using the default installation with JRE17. (I
manually removed my JRE11 installation before.) However, the "Java
Compiler" setting still reads "Use compliance from execution environment
'JavaSE-11' in the 'Java Build Path'" and on the bottom there is still
the warning, that 11 compliance is selected but 17 is used. If the
compliance is switched to 17, the warning disappears and the code builds
without errors as before.

Jan

On 13.04.2023 15:45, mark maker wrote:
> Hi all,
>
> On the *test* branch Jason lately switched to newer Java JDK versions
> 11, 17, 19. The new install4j installer now packs Java 17 (formerly 8).
> Older version are no longer supported (I think).
>
> Obviously this is great progress, but as always, some issues are to be
> expected:
>
> https://github.com/openpnp/openpnp/pull/1534
>
> As Niclas already mentioned, there are some Java Module issues with Eclipse:
>
> https://groups.google.com/g/openpnp/c/3dv0B3Me9uw/m/HloqU8kkBQAJ
>
> As far as I know, this is actually unrelated to the Java version
> changes, but this recent initiative also includes bumping a new build of
> openpnp-capture <https://github.com/openpnp/openpnp-capture>, the
> --
> You received this message because you are subscribed to the Google
> Groups "OpenPnP" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to openpnp+u...@googlegroups.com
> <mailto:openpnp+u...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/openpnp/09ed5f37-4624-23f8-192d-562b4fe7a379%40makr.zone <https://groups.google.com/d/msgid/openpnp/09ed5f37-4624-23f8-192d-562b4fe7a379%40makr.zone?utm_medium=email&utm_source=footer>.

mark maker

unread,
Apr 17, 2023, 7:12:13 AM4/17/23
to ope...@googlegroups.com

Hi Jan,

Personally, I installed a version 11 jdk, because that is the oldest version being supported by OpenPnP, and I do not want to inadvertently use new jdk capabilities.

I guess the "Compiler compliance level" should in theory also make sure of that, but it does not appear to be water tight. I got bit before when jdk 8 was the least support platform, tests would run fine, locally, but not inside the Github actions.

Under Windows/Preferences set the default JRE:

_Mark

Jarosław Karwik

unread,
Apr 17, 2023, 7:17:19 AM4/17/23
to OpenPnP
Have you ever considered releasing OpenPnp as docker container ? This would solve quite many issues like these .... introducing only small subset of new obes ( easier to solve)

Jan

unread,
Apr 17, 2023, 9:10:15 AM4/17/23
to ope...@googlegroups.com
Hi Mark!
Many thanks for your response! I'm trying to contribute and searched
for available information on how to do that. It seems, some is outdate
and some is missing:
- With the current (2023-03) version of the (Windows) Eclipse installer,
one gets JRE 17 as default. With this default the OpenPnP test branch
does build since this weekend and Jasons changes but it does not run.
- It was not obvious to me, that the JRE version is the problem and I
did not found any information (except the "compiler complience level"
deeply insight the project properties) which version to use.
- After manually installing JRE 11 (my Windows installation only
contains one line with the JRE 17 (probable the last line in you
screenshot) in "Installed JREs") and selecting it I can build and run
the test bunch.
I would apriciate if the Wiki could be updated to include the
required/recommended JRE version (for test and other relevant branches)
and how to install them.

Jan

On 17.04.2023 13:12, mark maker wrote:
> Hi Jan,
>
> Personally, I installed a version 11 jdk, because that is the oldest
> version being supported by OpenPnP, and I do not want to inadvertently
> use new jdk capabilities.
>
> I guess the "Compiler compliance level" should in theory also make sure
> of that
> <https://stackoverflow.com/questions/22584427/what-is-compiler-compliance-level-in-eclipse>, but it does not appear to be water tight. I got bit before when jdk 8 was the least support platform, tests would run fine, locally, but not inside the Github actions.
>
> Under Windows/Preferences set the default JRE:
>
> https://groups.google.com/d/msgid/openpnp/008b1337-42ed-c561-e3f2-e71e0d931402%40makr.zone <https://groups.google.com/d/msgid/openpnp/008b1337-42ed-c561-e3f2-e71e0d931402%40makr.zone?utm_medium=email&utm_source=footer>.

mark maker

unread,
Apr 17, 2023, 9:32:14 AM4/17/23
to ope...@googlegroups.com

> Have you ever considered releasing OpenPnp as docker container ?

In a certain sense this is already the case. Install4j brings its own JRE including VM which in all practical terms acts like a container. Consequently, just running OpenPnP is seldom the problem.

For development it is more difficult. On the one hand, Github actions for building, testing and deploying are already containerized. The simulated camera and GcodeServer classes inside OpenPnP allow for extensive testing against simulated hardware. On the other hand, if you want to develop and debug against the "real thing", USB-connected webcams and USB connected controllers make it at least difficult to run containerized. Also the classical (non-web) GUI is another complication, especially as OpenPnP wants to be cross-platform compatible.

_Mark

To unsubscribe from this group and stop receiving emails from it, send an email to openpnp+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openpnp/07301dbe-e241-4151-b74b-3e7314650af4n%40googlegroups.com.

mark maker

unread,
Apr 17, 2023, 9:38:15 AM4/17/23
to ope...@googlegroups.com

The reason I am reluctant to document this stuff in the Wiki is that I'm unsure about it. OpenPnP hacking is my only contact with Java. Figuring this stuff out is mostly just trial and error, then trying to throw some reasoning after it, mostly after the fact. 😇

_Mark

Jarosław Karwik

unread,
Apr 17, 2023, 9:39:53 AM4/17/23
to OpenPnP
I have been developing such application - with USB devices , ethernet and  GUI. Works nicely under Linux, but might be pain real pain under Windows. There is possibilty to use cross platform X server, but then we change one problem to another one.
And using full VM build is kind of to much for lower end computers.

Niclas Hedhman

unread,
Apr 17, 2023, 4:44:04 PM4/17/23
to ope...@googlegroups.com

One small detail that isn't well-known to non-java folks; Not all
releases/versions are created equally. 8, 11 and 17 are much more
deployed and has longer support cycles. All the ones in between, and
even 18, 19 and 20 are intended to release smaller features, but more
often, as well as one or more "incubating" cycles of new features
(letting features out in the wild but not committing to the final shape
of it until feedback).

The table on https://en.wikipedia.org/wiki/Java_version_history might
provide a great deal of guidance.


Hope that helps a little bit
Niclas


On 2023-04-17 15:38, mark maker wrote:
> The reason I am reluctant to document this stuff in the Wiki is that
> I'm unsure about it. OpenPnP hacking is my only contact with Java.
> Figuring this stuff out is mostly just trial and error, then trying to
> throw some reasoning after it, mostly _after_ the fact. 😇
>> [1], but it does not appear to be water tight. I got bit before when
>> <https://github.com/openpnp/openpnp-capture> [2], the underlying C++
> [3].
>
> --
> You received this message because you are subscribed to the Google
> Groups "OpenPnP" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to openpnp+u...@googlegroups.com
> <mailto:openpnp+u...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/openpnp/008b1337-42ed-c561-e3f2-e71e0d931402%40makr.zone
> <https://groups.google.com/d/msgid/openpnp/008b1337-42ed-c561-e3f2-e71e0d931402%40makr.zone?utm_medium=email&utm_source=footer>
> [4].
>
> --
> You received this message because you are subscribed to the Google
> Groups "OpenPnP" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to openpnp+u...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/openpnp/4eb0187b-8ba6-23be-c6d0-93d09b243f3f%40makr.zone
> [5].
>
>
> Links:
> ------
> [1]
> https://stackoverflow.com/questions/22584427/what-is-compiler-compliance-level-in-eclipse
> [2] https://github.com/openpnp/openpnp-capture
> [3]
> https://groups.google.com/d/msgid/openpnp/09ed5f37-4624-23f8-192d-562b4fe7a379%40makr.zone?utm_medium=email&amp;utm_source=footer
> [4]
> https://groups.google.com/d/msgid/openpnp/008b1337-42ed-c561-e3f2-e71e0d931402%40makr.zone?utm_medium=email&amp;utm_source=footer
> [5]
> https://groups.google.com/d/msgid/openpnp/4eb0187b-8ba6-23be-c6d0-93d09b243f3f%40makr.zone?utm_medium=email&utm_source=footer

Jan

unread,
Apr 18, 2023, 4:51:33 AM4/18/23
to ope...@googlegroups.com
I understand. It's the same for me: I'm not a native Java programmer and
don't know the projects requirements. Hopefully someone else is jumping
in and adds the missing pieces so that others can contribute more
easily. As always, I'm happy to assist and document my experience.

Jan

On 17.04.2023 15:38, mark maker wrote:
> The reason I am reluctant to document this stuff in the Wiki is that I'm
> unsure about it. OpenPnP hacking is my only contact with Java. Figuring
> this stuff out is mostly just trial and error, then trying to throw some
> reasoning after it, mostly /after/ the fact. 😇
> https://groups.google.com/d/msgid/openpnp/4eb0187b-8ba6-23be-c6d0-93d09b243f3f%40makr.zone <https://groups.google.com/d/msgid/openpnp/4eb0187b-8ba6-23be-c6d0-93d09b243f3f%40makr.zone?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages