4

I use Java 11 with JavaFX. When I added Apache MINA as a Maven dependency and then perform an import statement in the java class I get the following error message:

"The type org.apache.sshd.client.SshClient is not accessible"

I have added the dependency:

<dependency>
        <groupId>org.apache.sshd</groupId>
        <artifactId>sshd-core</artifactId>
        <version>2.8.0</version>
</dependency>

Then I import into class:

import org.apache.sshd.client.SshClient;

But it doesn't work. I get the above error. What am I doing wrong? Please help.

qingy2019
  • 536
  • 7
  • 23
sm-a
  • 65
  • 3
  • Is it a modular app? Do you have a module info? It could be a module access issue, but I don’t know from the description. The Mina library isn’t modular as far as I can tell, so it may be easier to access if you have no module info, but it could be another issue. What is creating the error? Is it an IDE inspection error or the output of the maven compile step? Is there any more relevant info about the error? Can you get the library to work in a console app that does not use JavaFX? Did you reimport the maven file to update the IDE project after adding the dependency? – jewelsea Mar 04 '22 at 07:41
  • Yes it is a modular app. When I try 'requires org.apache.sshd;' in module info I get the following error: org.apache.sshd cannot be resolved to a module. IDE inspection error="The type org.apache.sshd.client.SshClient is not accessible" the maven compile error is: "package org.apache.sshd.client is not visible". I try tonight create an console app. Yes, I have reimported the maven file in Eclipse. – sm-a Mar 04 '22 at 09:40
  • You can edit the question to add more info, that often works better. When doing so, you can quote comments if that helps. Try creating a non modular app without a module info and adding JavaFX modules through command line switches, refer to the relevant doc at openjfx.io getting started. If you try to continue with a modular app, you don’t require packages, you require modules. Mina and its dependencies will probably be automatic modules, study a module tutorial to understand how such modules are named. – jewelsea Mar 04 '22 at 11:18
  • 1
    @jewelsea Perfect. I have creating a non modular app without a module info and it works. Thank you. – sm-a Mar 04 '22 at 22:47

1 Answers1

2

The Mina library 2.8.0 isn’t modular as far as I can tell, so it will probably be easier to access and use it if you have no module info.

Create a non modular app without a module info.java file. Place your application code and the Mina libraries and dependencies on the class path. Add JavaFX modules through command line switches as those need to be accessed via the module path, not the class path.

Refer to the relevant documentation on non-modular applications at openjfx.io getting started.

jewelsea
  • 150,031
  • 14
  • 366
  • 406