I am going to run some Java files ending with .class and .jar. How could I run these files inside of MATLAB?
1 Answer
The article Bringing Java Classes into MATLAB Workspace should be referenced for a thorough explanation of MATLAB's dynamic Java class path and how to add third-party and user-defined classes, but here are the Cliff's Notes:
Use javaaddpath to add Java archives (JAR files) or folders containing Java classes:
javaaddpath('C:\Folder\with\class\files\')
javaaddpath('C:\Path\to\jarfile.jar')
Then use javaclasspath('-dynamic') to see the dynamic class path, which should now reflect your additions.
To add to the static path, you'll need to edit javaclasspath.txt.
The import command can then be used to add classes or full packages to the import list.