0

I am having trouble running a java package I made by deploying my function in matlab. This is what I have tried and these are my errors.

I deployed a jar file of my function from matlab. I tried to run it with the following steps: 1. change the LD_LIBRARY_PATH

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/runtime/glnxa64/:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/:opencv

  1. in the deployed project, my classes are in a folder called javafiles so I run it as:

java -cp ../javafiles.jar:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/toolbox/javabuilder/jar/javabuilder.jar:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwMATLAB_imagesci_res.so:mex:opencv/. -Djava.library.path=/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/runtime/glnxa64/ javafiles.Class1

Here opencv and mex are folders in the current directory which contain some shared libraries and mex files required to run my project. Upon doing this I get the error:

Exception in thread "main" java.lang.NoClassDefFoundError: com/mathworks/toolbox/javabuilder/internal/MWComponentInstance at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:800) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482) Caused by: java.lang.ClassNotFoundException: com.mathworks.toolbox.javabuilder.internal.MWComponentInstance at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 13 more

Thank you in advance for your help.

user3246971
  • 233
  • 2
  • 6
  • 1) did you first try compiling it using `javac`? If so, post the full command that you used. 2) ur `so` file should be there in `java.library.path`, not in `classpath` 3) ur `java` command above seems incomplete. Which is the main class are you running here? – Pat Aug 02 '14 at 07:33
  • I am trying to run `javafiles.Class1` its a bit confusing in the formatting, there is a space between `Djava.library.path=/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/runtime/glnxa64/` and `javafiles.Class1` – user3246971 Aug 02 '14 at 16:24

0 Answers0