1

I am going to run some Java files ending with .class and .jar. How could I run these files inside of MATLAB?

1
  • Try this: Link Commented Mar 15, 2014 at 6:30

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.