-1

I have following problem that have been reported several times (link1, link2, link3, link4, link5, etc). But I could not find a clear answer.

I just edited the name of project and basic information in the template of this project example-imagej-command;

when I try to build with Maven in eclipse;

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/cosacak/.p2/pool/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/C:/Users/cosacak/eclipse/java-2020-12/eclipse/configuration/org.eclipse.osgi/5/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/cosacak/.p2/pool/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/C:/Users/cosacak/eclipse/java-2020-12/eclipse/configuration/org.eclipse.osgi/5/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------< de.kizillab.org:MyExamplePlugin >-------------------
[INFO] Building My Example Plugin 1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-enforcer-plugin:1.4.1:enforce (enforce-rules) @ MyExamplePlugin ---
[INFO] Adding ignore: module-info
[INFO] Adding ignore: META-INF/versions/*/module-info
[INFO] Adding ignore: org.apache.hadoop.yarn.*.package-info
[INFO] Adding ignore: org.apache.spark.unused.UnusedStubClass
[INFO] Adding ignore: org.hibernate.stat.ConcurrentStatisticsImpl
[INFO] Adding ignore: org.junit.runner.Runner
[INFO] Adding ignore: module-info
[WARNING] Rule 2: org.apache.maven.plugins.enforcer.RequireJavaVersion failed with message:
Detected JDK Version: 15.0.2 is not in the allowed range [1.8.0-101,1.8.9999].
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  8.330 s
[INFO] Finished at: 2021-03-31T02:49:00+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.4.1:enforce (enforce-rules) on project MyExamplePlugin: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Now if I run as Java Application using eclipse;

    log4j:WARN No appenders could be found for logger (org.bushe.swing.event.EventService).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
[ERROR] Cannot create plugin: class='org.scijava.plugins.scripting.javascript.JavaScriptScriptLanguage', name='JavaScript', priority=0.0, enabled=true, pluginType=ScriptLanguage
java.lang.IllegalArgumentException: No such script engine: javascript
    at org.scijava.script.AdaptedScriptLanguage.findFactory(AdaptedScriptLanguage.java:152)
    at org.scijava.script.AdaptedScriptLanguage.<init>(AdaptedScriptLanguage.java:74)
    at org.scijava.plugins.scripting.javascript.JavaScriptScriptLanguage.<init>(JavaScriptScriptLanguage.java:59)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
    at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128)
    at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:350)
    at java.base/java.lang.Class.newInstance(Class.java:645)
    at org.scijava.plugin.PluginInfo.createInstance(PluginInfo.java:306)
    at org.scijava.plugin.DefaultPluginService.createInstance(DefaultPluginService.java:237)
    at org.scijava.plugin.DefaultPluginService.createInstances(DefaultPluginService.java:226)
    at org.scijava.plugin.DefaultPluginService.createInstancesOfType(DefaultPluginService.java:217)
    at org.scijava.plugin.AbstractSingletonService.initInstances(AbstractSingletonService.java:138)
    at org.scijava.plugin.AbstractSingletonService.getInstances(AbstractSingletonService.java:77)
    at org.scijava.plugin.SingletonService.lambda$initialize$0(SingletonService.java:97)
    at org.scijava.object.ObjectIndex.resolvePending(ObjectIndex.java:388)
    at org.scijava.object.ObjectIndex.get(ObjectIndex.java:133)
    at org.scijava.object.DefaultObjectService.getObjects(DefaultObjectService.java:87)
    at org.scijava.display.DefaultDisplayService.getDisplays(DefaultDisplayService.java:166)
    at org.scijava.ui.DefaultUIService.showUI(DefaultUIService.java:159)
    at org.scijava.ui.DefaultUIService.showUI(DefaultUIService.java:142)
    at de.kizillab.org.MyExamplePlugin.main(MyExamplePlugin.java:85)
[ERROR]: Cannot locate JRE jar in C:\Users\cosacak\.p2\pool\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_15.0.2.v20210201-0955\jre
[ERROR] Cannot create plugin: class='org.scijava.ui.swing.script.languagesupport.JavaLanguageSupportPlugin', priority=0.0, enabled=true, pluginType=LanguageSupportPlugin
java.lang.IllegalArgumentException: info cannot be null
    at org.fife.rsta.ac.java.JarManager.addClassFileSource(JarManager.java:157)
    at org.fife.rsta.ac.java.JarManager.addCurrentJreClassFileSource(JarManager.java:193)
    at org.scijava.ui.swing.script.languagesupport.JavaLanguageSupportPlugin.<init>(JavaLanguageSupportPlugin.java:56)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
    at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128)
    at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:350)
    at java.base/java.lang.Class.newInstance(Class.java:645)
    at org.scijava.plugin.PluginInfo.createInstance(PluginInfo.java:306)
    at org.scijava.plugin.DefaultPluginService.createInstance(DefaultPluginService.java:237)
    at org.scijava.plugin.DefaultPluginService.createInstances(DefaultPluginService.java:226)
    at org.scijava.plugin.DefaultPluginService.createInstancesOfType(DefaultPluginService.java:217)
    at org.scijava.plugin.AbstractSingletonService.initInstances(AbstractSingletonService.java:138)
    at org.scijava.plugin.AbstractSingletonService.getInstances(AbstractSingletonService.java:77)
    at org.scijava.plugin.SingletonService.lambda$initialize$0(SingletonService.java:97)
    at org.scijava.object.ObjectIndex.resolvePending(ObjectIndex.java:388)
    at org.scijava.object.ObjectIndex.get(ObjectIndex.java:133)
    at org.scijava.object.DefaultObjectService.getObjects(DefaultObjectService.java:87)
    at org.scijava.display.DefaultDisplayService.getDisplays(DefaultDisplayService.java:166)
    at org.scijava.ui.DefaultUIService.showUI(DefaultUIService.java:159)
    at org.scijava.ui.DefaultUIService.showUI(DefaultUIService.java:142)
    at de.kizillab.org.MyExamplePlugin.main(MyExamplePlugin.java:85)
[INFO] Found 10 JHotDraw adapters.
sanjeevRm
  • 1,541
  • 2
  • 13
  • 24
m.i.cosacak
  • 708
  • 7
  • 21
  • 5
    The build script obviously want to enforce that you **build using Java 8**, so how about you honor the restriction and install Java 8 and use that when building? --- As for the `No such script engine: javascript` error, the JavaScript scripting engine was removed in Java 15. If you change to use the Java 8 the program obviously wants, you'll get your JavaScript too. – Andreas Mar 31 '21 at 02:05
  • Here is the java version, do I have to downgrade to 8 or is there a way to do it in eclipse installation: `java version "16" 2021-03-16 Java(TM) SE Runtime Environment (build 16+36-2231) Java HotSpot(TM) 64-Bit Server VM (build 16+36-2231, mixed mode, sharing)` – m.i.cosacak Mar 31 '21 at 13:39
  • 1
    I told you to install Java 8. If you need help installing Java 8, then create a new question and ask for it, but asking if you need to downgrade to 8 when I already told you to install 8 is just ... *(sorry, can't find word to use)* --- Yes, there is a way to use Java 8 in Eclipse. But how much help is it knowing that? Wouldn't it be better to ask *how* to do it with Eclipse? Of course, you could just do a web search to find the answer, but let's not get into that. --- Perhaps you should consider how better to [ask a good question](https://stackoverflow.com/help/how-to-ask). – Andreas Mar 31 '21 at 15:01

3 Answers3

0

As an alternative to eclipse, one may simply use Maven on linux or any operating system that has Maven installed.

Here the version on linux is :

>java -version

openjdk version "1.8.0_282"
OpenJDK Runtime Environment (build 1.8.0_282-8u282-b08-0ubuntu1~20.04-b08)
OpenJDK 64-Bit Server VM (build 25.282-b08, mixed mode)

and maven version is:

>mvn -version

Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 1.8.0_282, vendor: Private Build, runtime: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.4.0-60-generic", arch: "amd64", family: "unix"

now simply running:

mvn compile
mvn package

solves the problem.

if I find a solution with eclipse or netbeans, I will post the answer for that as well.

m.i.cosacak
  • 708
  • 7
  • 21
0

For window users, if you have Maven project, Maven is also available and can be used to compile/package as can be done on Linux (see my answer above). As a result, in case one has the problem above while building a project in eclipse and does not have Linux as well, can use Maven on windows as well.

Now I am writing my scripts/projects in eclipse and using Maven command to compile/package as below;

Download Maven zip file from here and unzip it anywhere on windows, does not have to be in your project folder. Add maven \bin in PATH. The bin file has maven.cmd in e.g., apache-maven-3.6.3-bin\apache-maven-3.6.3\bin folder after unzipping.

now open command terminal in windows, use cd to navigate to the project folder which have pom.xml file as well. In my case;

cd Documents\eclipse-workspace\example-imagej-command-master

mvn compile
mvn package

it works as well on windows.

m.i.cosacak
  • 708
  • 7
  • 21
0

And finally, I could solve the problem with eclipse on windows. In order to build the package the solution from this question worked for eclipse on Windows:

In brief;

Go to;

windows -> preferences -> Installed JREs

then press Add -> Start VM press Next, Choose JRE home by "Directory" as path2Fiji\Fiji\java\win64\jdk1.8.0_172

Finally, select jdk from FiJi and "Apply and Close".

Now, eclipse should be able build Maven project on Windows.

m.i.cosacak
  • 708
  • 7
  • 21