How to use java class that I made in matlab?

16 views (last 30 days)
JINSOL.KIM
JINSOL.KIM on 16 Nov 2015
Commented: Kirby Fears on 17 Nov 2015
How to use java class that I made in matlab?
I made a package. So, I want to use it in the MATLAB. But I can't do it.
ex) import java.lang.String, which is possible.
But the class that I made is unaccessible. How can I import mine?
or Where should I save my package?
please help me...
  1 Comment
Adam
Adam on 16 Nov 2015
As far as I am aware it should simply be on your path and compiled into .class (I think) files.

Sign in to comment.

Accepted Answer

Kirby Fears
Kirby Fears on 16 Nov 2015
Edited: Kirby Fears on 16 Nov 2015
Matlab has a java session that will only see your package if it's on that session's class path. You'll be able to import your package after adding it to the class path using javaaddpath() in Matlab. For example:
filepath = 'C:/mypackage.jar'
javaaddpath(filepath);
import mypackage.Class1; % imports Class 1 within mypackage
Hope this helps.
  2 Comments
Kirby Fears
Kirby Fears on 17 Nov 2015
Your classname is "Vector2", not "Vetor2". Does import work when you correct the spelling?

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!