Note that there are some explanatory texts on larger screens.

plurals
  1. POMatlab doesn't see .jar file
    primarykey
    data
    text
    <p>Ok, I'm stumped here. I'm using Matlab version 2013b with a Java RTE of 1.7.0_11 and I'm trying to run a simple piece of code to see if Matlab is able to read the .jar file and nothing seems to be working.</p> <p>Here is the Java code, which is compiled to a .jar named JavaOCT.jar, which is placed in the Matlab working directory:</p> <pre><code>package VTK; public class vtkVolumeView{ public int Test(){ return 10; } } </code></pre> <p>That is it, no other dependencies, nothing fancy. In Matlab, I try:</p> <pre><code>javaaddpath('\JavaOCT.jar'); %&lt;-Directory and name are 100% correct import VTK.*; %&lt;-Package name from above methodsview VTK.vtkVolumeView; %&lt;-Can't find the class, argh! </code></pre> <p>Matlab kicks back that it can't find the class.</p> <p>Things I've done to try and solve the problem:</p> <ol> <li>Reverted to the exact same JDK as the Matlab RTE</li> <li>Tried an older 1.6 JDK</li> <li>Done lots of stack overflow research to try and solve it <a href="https://stackoverflow.com/questions/9520503/calling-java-from-matlab">1</a> <a href="https://stackoverflow.com/questions/14219589/matlab-javaaddpath-not-working-anymore-with-jar-built-with-jdk-1-7">2</a> <a href="https://stackoverflow.com/questions/8499890/matlab-cannot-see-some-of-my-java-classes-not-all-in-jar-package">3</a> <a href="https://stackoverflow.com/questions/11053664/use-java-in-matlab">4</a></li> <li>Tried used <code>javaclasspath</code> and pointing to the compiled class instead</li> <li>Read the Matlab documentation <a href="http://www.mathworks.com/help/matlab/matlab_external/bringing-java-classes-and-methods-into-matlab-workspace.html" rel="nofollow noreferrer">5</a> </li> <li>Using <code>clear -java</code> after the <code>javaaddpath</code></li> </ol> <p>Any help would be appreciated, it is driving me nuts!</p> <p>Update: Daniel R suggested just <code>javaaddpath('JavaOCT.jar')</code> which doesn't work either.</p> <p>Final update: It finally works! I wasn't building the .jar properly. In IntelliJ, click on the project and hit F4. This brings up the Project Structure, then go to Artifacts and click the green + button and add <code>DirectoryContent</code> and then point to the <code>out\production</code>. Once this is done, as mentioned by others, it should show up in Matlab as an expandable .jar.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload