Requirements to use functions from my own jar file
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi, I am trying to use my java functions in Matlab. I know how to add jar file to Matlab path. I know that I am supoused to put constructor in my java class (I don't know why, but MatLab cannot find it without constructor). And even with the constructor I am not able to call my functions if they are in some packege. It works only when placed in default package, when the class file is in root of the jar file.
clear all, close all, clc
javaaddpath(fullfile(pwd,'myTestFunction.jar'))
%Check if it is added
javaclasspath
%%a. Call Public Static Functions of the Class
% Public static functions of a Java class can be called without having to create an instance of that class.
TestFunction.main('') % Call public static functions of the HelloWorld class
%%b. Create an Instance of the Class
% To create an instance of my class, issue the following command at the MATLAB command prompt:
instance = TestFunction % Create an instance of the class through the constructor
%%c. Call method of the Class
instance.Add(5)
instance.Add(5)
- Am I making something wrong with my java code or jar export?
- Is there a way to use classes if they are in package(s)?
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Call Java from MATLAB에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!