2

I want to migrate my old java code to the java9 modules. E.g. in the classpath there is a jar-file named org.eclipse.jface.3.7.0.v20110928.jar. In the classpath it is referenced as org.eclipse.jface_3.7.0.v20110928.jar. The point in the filename after jface is replaced with an underscore in the classpath. Don't know how it works. Maybe it is because .3.7.0. is not a legal java identifier.

But now I want to use it as a module. I get an error for the modulename. The part '.7.0.' is not allowed, because a number can not be a java identifier. The underscore is a reserved word in java9.

First I used the same name for the module as it saw it in the classpath (org.eclipse.jface_3.7.0.v20110928.jar). But it is an error. The I tried to use the name of the file (org.eclipse.jface.3.7.0.v20110928.jar), same error.

module iDEpdf.src 
{
    exports org.idepdf.ri.common.utility.annotation;
    ...
    requires org.eclipse.jface.3.7.0.v20110928;
}

'.3.7.0' is marked and the error is 'illegal token'. When I use org.eclipse.jface_3.7.0.v20110928 the marked substring is '.7.0'. The error is the same.

If it is possible I don't want to rename the jar-file. I don't understand how it works for the classpath and I don't understand why it does not work for the module. How should I handle this?

jboockmann
  • 1,011
  • 2
  • 11
  • 27
hunter3
  • 21
  • 2
  • You probably will need to rename it, if only to change `_3` to `-3`. The hyphen is treated as the start of the version when determining an automatic module name. See [the documentation of ModuleFinder](https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/lang/module/ModuleFinder.html#of%28java.nio.file.Path...%29). – VGR Aug 22 '19 at 18:46

1 Answers1

0

I think you are using a very old library of JFace. You probably need to update or add Automatic-Module-Name.

Since the library doesn’t have a module descriptor yet, the module isn’t recognized as valid.

My question is also: why migrate to the module system before updating libraries to recent versions?

Please also see this question or this one.

Michiel Leegwater
  • 1,172
  • 4
  • 11
  • 27
  • The software is old and runs on many computers. Now I need to extend the algorithm part of the software. I want to use lambdas, streams and so on. So I use the newst eclipse IDE and java 12. The eclipse IDE comes without any libraries, so I decided to use the old libraries for the moment. Java12 comes without JRE, so I want to use the module system to build the runtime with jlink. You are right. First I will change the libraries to the newes versions. Then we will see. The Modulfinder documentation is interesting. It helps me to understand what happens. – hunter3 Aug 23 '19 at 07:19
  • Java 9+ migration does not require you to move out of the classpath oriented world! The regular migration advise is to first just run on Java 9 using classpath, then start thinking about modularizing. – Michiel Leegwater Aug 23 '19 at 07:34
  • Yes, with classpath the software runs without problems omn java9 or java12. Iwant to use java12. But there is no JRE in java 12. But I can create a Runtime with jlink. Maybe this is possible with a classpath project, but it would be much more nice to have it modularised.. – hunter3 Aug 23 '19 at 13:57
  • Now I try to change all the old libraries with the current versions. The eclipse IDE 2019/6 cames without plugins, so I tried to find the libraries in maven repositories. Some of them I found, some other I did not (E.g. org.eclipse.swt.win32.win32.x86_64). Is there a place where I can find all the eclipse plugins for maven-use?. – hunter3 Aug 23 '19 at 14:07
  • now I use the newest version of the eclipse plugins. I downloaded the eclipse platform to have consistent libraries. The plugins are still not modulariable. The same packages are in more plugins. e.g. eclipse.core.runtime is in the plugins org.ecluipse.core.rz – hunter3 Sep 06 '19 at 15:42