Hi All I have lost track of the jar creation process in the examples module. Everytime before commiting I have executed examples using Eclipse IDE which ran successfully. I need to modify the examples module. Sorry for any inconvenience. Please find my additional responses below.
>There are issues with the expected functionality of the "examples-ga" module. >Assuming that the following command has been issued > $ JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/ mvn package >and has completed successfully, executable JAR files should have been >created under the "target" directories. >For example, issuing this command (example for the "neuralnet" module): > $ java -jar commons-math-examples/examples-sofm/tsp/target/examples-sofm-tsp.jar >outputs >---CUT--- >Missing required option '-o=outputFile' >Usage: <main class> [-hV] [-j=numJobs] [-m=maxTrials] [-n=neuronsPerCity] > -o=outputFile [-s=numSamples] >Run the application > -h, --help Show this help message and exit. > -j=numJobs Number of concurrent tasks (default: 8). > -m=maxTrials Maximal number of trials (default: 10). > -n=neuronsPerCity Average number of neurons per city (default: 2.2). > -o=outputFile Output file name. > -s=numSamples Number of samples for the training (default: 2000). > -V, --version Print version information and exit. >---CUT--- >The above thus shows that the program runs as expected (passing the missing >required argument produces the expected output file). >Doing the equivalent for the new examples, e.g. > $ java -jar commons-math-examples/examples-ga/examples-ga-tsp/target/examples-ga-mathfunctions.jar >results in >---CUT--- >Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load >library: /usr/lib/jvm/java-11-openjdk-amd64/lib/libawt_xawt.so > at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2630) > at java.base/java.lang.Runtime.load0(Runtime.java:768) > at java.base/java.lang.System.load(System.java:1837) > at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method) > at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2442) > at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2498) > at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2694) > at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2648) > at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:830) > at java.base/java.lang.System.loadLibrary(System.java:1873) > at java.desktop/java.awt.Toolkit$3.run(Toolkit.java:1399) > at java.desktop/java.awt.Toolkit$3.run(Toolkit.java:1397) > at java.base/java.security.AccessController.doPrivileged(Native Method) > at java.desktop/java.awt.Toolkit.loadLibraries(Toolkit.java:1396) > at java.desktop/java.awt.Toolkit.<clinit>(Toolkit.java:1429) > at java.desktop/java.awt.Component.<clinit>(Component.java:621) > at org.apache.commons.math4.examples.ga.tsp.TSPOptimizer.main(TSPOptimizer.java:62) >---CUT--- >[Please note that the name of the JAR also looks wrong (a copy/paste mistake?).] --There is an issue in the jar file name. But in my system the TSP application executed successfully. The commands I have executed are given below: $ mvn package $ java -jar examples-ga-mathfunctions.jar JDK version in my local system is "1.8.0_301" --In the mvn command specified by you JAVA_HOME is assigned as "/usr/lib/jvm/java-8-openjdk-amd64/" but during execution of jar it is using java-11 Could you please confirm what is the JDK version used and ensure same version is used for both. This issue usually comes if the JDK is not properly installed. >Command > $ java -jar commons-math-examples/examples-ga/examples-ga-math-functions/target/examples-ga-mathfunctions.jar >also fails, with the following error >---CUT--- >Error: Could not find or load main class >org.apache.commons.math4.examples.ga.mathfunctions.Dimension2FunctionOptimizer >Caused by: java.lang.ClassNotFoundException: >org.apache.commons.math4.examples.ga.mathfunctions.Dimension2FunctionOptimizer >---CUT--- -- This is due to the wrong package name. I introduced a sub package based on dimension but forgot to modify the same in the pom file. >I noticed that there is an example relating to "Dimension2" and another >to "DimensionN". Isn't the former, in principle, a special case of the latter? --Yes, the former is the special case of the latter. But the way the executable jar is generated I need to keep a single java file with the main method and the number of dimensions needs to be passed as a program argument. --I shall make the changes and create a PR for the new feature branch. Thanks & Regards --Avijit Basak On Sun, 9 Jan 2022 at 01:01, Gilles Sadowski <gillese...@gmail.com> wrote: > Hello. > > I've also started to take a look. > > There are issues with the expected functionality of the "examples-ga" > module. > > Assuming that the following command has been issued > $ JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/ mvn package > and has completed successfully, executable JAR files should have been > created under the "target" directories. > > For example, issuing this command (example for the "neuralnet" module): > $ java -jar > commons-math-examples/examples-sofm/tsp/target/examples-sofm-tsp.jar > outputs > ---CUT--- > Missing required option '-o=outputFile' > Usage: <main class> [-hV] [-j=numJobs] [-m=maxTrials] [-n=neuronsPerCity] > -o=outputFile [-s=numSamples] > Run the application > -h, --help Show this help message and exit. > -j=numJobs Number of concurrent tasks (default: 8). > -m=maxTrials Maximal number of trials (default: 10). > -n=neuronsPerCity Average number of neurons per city (default: 2.2). > -o=outputFile Output file name. > -s=numSamples Number of samples for the training (default: 2000). > -V, --version Print version information and exit. > ---CUT--- > > The above thus shows that the program runs as expected (passing the missing > required argument produces the expected output file). > > Doing the equivalent for the new examples, e.g. > $ java -jar > commons-math-examples/examples-ga/examples-ga-tsp/target/examples-ga-mathfunctions.jar > results in > ---CUT--- > Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load > library: /usr/lib/jvm/java-11-openjdk-amd64/lib/libawt_xawt.so > at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2630) > at java.base/java.lang.Runtime.load0(Runtime.java:768) > at java.base/java.lang.System.load(System.java:1837) > at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method) > at > java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2442) > at > java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2498) > at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2694) > at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2648) > at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:830) > at java.base/java.lang.System.loadLibrary(System.java:1873) > at java.desktop/java.awt.Toolkit$3.run(Toolkit.java:1399) > at java.desktop/java.awt.Toolkit$3.run(Toolkit.java:1397) > at java.base/java.security.AccessController.doPrivileged(Native Method) > at java.desktop/java.awt.Toolkit.loadLibraries(Toolkit.java:1396) > at java.desktop/java.awt.Toolkit.<clinit>(Toolkit.java:1429) > at java.desktop/java.awt.Component.<clinit>(Component.java:621) > at > org.apache.commons.math4.examples.ga.tsp.TSPOptimizer.main(TSPOptimizer.java:62) > ---CUT--- > > [Please note that the name of the JAR also looks wrong (a copy/paste > mistake?).] > > Command > $ java -jar > commons-math-examples/examples-ga/examples-ga-math-functions/target/examples-ga-mathfunctions.jar > also fails, with the following error > ---CUT--- > Error: Could not find or load main class > > org.apache.commons.math4.examples.ga.mathfunctions.Dimension2FunctionOptimizer > Caused by: java.lang.ClassNotFoundException: > > org.apache.commons.math4.examples.ga.mathfunctions.Dimension2FunctionOptimizer > ---CUT--- > > I noticed that there is an example relating to "Dimension2" and another > to "DimensionN". Isn't the former, in principle, a special case of the > latter? > > > Regards, > Gilles > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > For additional commands, e-mail: dev-h...@commons.apache.org > > -- Avijit Basak