How to use jar file developed by MATLAB in java using Netbeans

9 vues (au cours des 30 derniers jours)
Soumadeep de
Soumadeep de le 17 Déc 2019
Commenté : Andrew Janke le 31 Jan 2020
I am trying to create an application where the user interface is in Java (using Netbeans) and the back end computation is in an m file. I created the jar file with deploytool in MTALB. I have cretated a dependency (it's a maven application) for java builder and this jar file in Netbeans. The m file expects 2 integer input and returns an array of flod values.
I am calling this jar file in Netbeans by using following code: -
Class1 x = null;
Object result[] = null;
MWNumericArray in = null;
MWNumericArray out = null;
try {
x = new Class1();
in = new MWNumericArray();
result = x.add(1, in);
out = (MWNumericArray) result[0];
System.out.println(out);
} catch (MWException ex) {
Logger.getLogger(HarmonicFilter.class.getName()).log(Level.SEVERE, null, ex);
}
When I run the application, I get the following error: -
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.mathworks.toolbox.javabuilder.internal.MCRThreadUtilities$1 (file:/C:/Users/212686096/.m2/repository/unknown/binary/javabuilder/1.0/javabuilder-1.0.jar) to method java.awt.EventQueue.dispatchEvent(java.awt.AWTEvent)
WARNING: Please consider reporting this to the maintainers of com.mathworks.toolbox.javabuilder.internal.MCRThreadUtilities$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Error using checkRequiredMCRProducts (line 25)
Java exception occurred:
java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3167)
at java.base/java.lang.Class.getDeclaredMethods(Class.java:2310)
at com.google.inject.spi.InjectionPoint.getInjectionPoints(InjectionPoint.java:662)
at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:356)
at com.google.inject.internal.ConstructorBindingImpl.getInternalDependencies(ConstructorBindingImpl.java:151)
at com.google.inject.internal.InjectorImpl.getInternalDependencies(InjectorImpl.java:585)
at com.google.inject.internal.InjectorImpl.cleanup(InjectorImpl.java:543)
at com.google.inject.internal.InjectorImpl.initializeJitBinding(InjectorImpl.java:529)
at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:847)
at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:772)
at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:256)
at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:205)
at com.google.inject.internal.InjectorImpl.getInternalFactory(InjectorImpl.java:853)
at com.google.inject.internal.FactoryProxy.notify(FactoryProxy.java:46)
at com.google.inject.internal.ProcessedBindingData.runCreationListeners(ProcessedBindingData.java:50)
at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:133)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:106)
at com.google.inject.Guice.createInjector(Guice.java:95)
at com.google.inject.Guice.createInjector(Guice.java:72)
at com.google.inject.Guice.createInjector(Guice.java:62)
at com.mathworks.install.InstalledProductFactory$InstallerWorkSpace.createInjector(InstalledProductFactory.java:113)
at com.mathworks.install.InstalledProductFactory$InstallerWorkSpace.executeTask(InstalledProductFactory.java:187)
at com.mathworks.install.InstalledProductFactory$InstallerWorkSpace.access$200(InstalledProductFactory.java:108)
at com.mathworks.install.InstalledProductFactory.getInstalledProducts(InstalledProductFactory.java:67)
Error in deployrc (line 9)
Error in matlabrc (line 238)
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_UNCAUGHT_CXX_EXCEPTION (0xe06d7363) at pc=0x00007ff922449129, pid=9664, tid=20384
#
# JRE version: Java(TM) SE Runtime Environment (13.0.1+9) (build 13.0.1+9)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (13.0.1+9, mixed mode, sharing, tiered, compressed oops, g1 gc, windows-amd64)
# Problematic frame:
# C [KERNELBASE.dll+0x39129]
#
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\212686096\Documents\NetBeansProjects\CASYS_V3\hs_err_pid9664.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)
at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:764)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:711)
at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:289)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 25.807 s
Finished at: 2019-12-17T16:06:22+05:30
Final Memory: 7M/27M
------------------------------------------------------------------------
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.5.0:exec (default-cli) on project CASYS_V3: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.
For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Please help me with this.
  1 commentaire
Andrew Janke
Andrew Janke le 31 Jan 2020
"Illegal reflective access"? Sounds like you've got something compiled for an older version of Java running on Java 9+. What versions of everything are you using?

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Java Package Integration dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by