MATLAB Answers

calling a java class from matlab

24 views (last 30 days)
I have a java class, and I need to call it from matlab to implement a document. is that you have an idea?

Accepted Answer

Richard Alcock
Richard Alcock on 6 May 2011
It depends on whether it has been packaged into a .jar file or is a .class file.
Your class is called hello.HelloWorld
If it's in a file called c:\work\hello\HelloWorld.class, you need to add the root directory to the class path.
javaaddpath c:\work\
function Test()
hello.HelloWorld();
end
On the other hand, if it's in a c:\work\hello.jar file, you add the jar file to the class path.
javaaddpath c:\work\hello.jar
After that's it's the same.
  11 Comments
Richard Alcock
Richard Alcock on 24 May 2011
I need some more information:
1. What is the full path to HelloWorld.class file?
2. What is the exact javaaddpath command you ran in MATLAB?
3. What error are you getting from MATLAB

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!