calling a java class from matlab
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
I have a java class, and I need to call it from matlab to implement a document. is that you have an idea?
채택된 답변
Richard Alcock
2011년 5월 6일
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
I add the path and when I call:
{
% Construct an instance
obj = najmaf.Najma;
}
it gives me this error:
??? Undefined function or variable 'HelloWorld'.
HelloWorld it's my class file
What is the full name of your class?
Is it in a jar file?
No, is a simple Java class called: HelloWorld.class
this is the code:
{
package hello;
import java.lang.String;
public class HelloWorld {
//package mypack;
public String hello;
public HelloWorld() {
hello = "world";
}
}
}
i called this class from matlab with:
{
function Test()
test = HelloWorld();
end
}
it gives me the error:
{
??? Undefined function or variable 'HelloWorld'.
Error in ==> Test at 3
test = HelloWorld();
}
do you have any suggestion???
do you have any suggestion???
I've updated my answer.
I received nothing.
I sent you the class with which I work with the error I received
najmaf najma
2011년 5월 14일
is that you can send me your reply again because I have not received the update that you did
Neha
2011년 5월 21일
Hey Richard,
I have this query I'm troubling since long with it.
I need to invoke a java class in Matlab, and need to store the returned string value in a variable in Mtalab. for this query i got following solution from a website, plz tell me where its going wrong:
>>
The Hello World solution by The MathWorks provides some insights on how to run a simple 'Hello World' java application inside MATLAB. You may change the Java code a bit, in order to have a method that returns a String.
public class HelloWorld
{
public String hello()
{
String helloWorld = "Hello World!";
return helloWorld;
}
}
Once this simple class is compiled and on the MATLAB JVM classpath create an instance and invoke the method with the following two commands.
o = HelloWorld
output = o.hello;
The String returned by the HelloWorld instance is assigned to the MATLAB variable output.
<<
The command described to invoke java code in matlab(ie o=HelloWorld) gives error.
Richard Alcock
2011년 5월 24일
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
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Call Java from MATLAB에 대해 자세히 알아보기
제품
참고 항목
2011년 5월 6일
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
