How to use 'jar' in matlab m file?

I have the 'jar' file and the usage of (the classes contained in jar) in java code is like the following:
[code java] import kr.hyosang.coordinate.*;
........
CoordPoint pt = new CoordPoint(126.97553009053178, 37.56456569639763);
CoordPoint ktmPt = TransCoord.getTransCoord(pt, TransCoord.COORD_TYPE_WGS84, TransCoord.COORD_TYPE_KTM);
[/code]
------------------------------------------------------------------
And this is my matlab code which has a problem to run.
clc; clear all;
javaaddpath('TransCoord.jar')
import kr.hyosang.coordinate.*;
CP=CoordPoint
methods(CP)
pt=CP(126.97553009053178, 37.56456569639763)
clear import
clear java
-----------------------------------------------------
I know nothing whatever about JAVA. But the only ting I want to do is
CoordPoint pt = new CoordPoint(126.97553009053178, 37.56456569639763);
CoordPoint ktmPt = TransCoord.getTransCoord(pt, TransCoord.COORD_TYPE_WGS84, TransCoord.COORD_TYPE_KTM);
to run these two lines in my matlab code.

Antworten (1)

Titus Edelhofer
Titus Edelhofer am 25 Jul. 2016

0 Stimmen

Hi,
this should work right away:
pt = CoordPoint(126.97553009053178, 37.56456569639763);
ktmPt = TransCoord.getTransCoord(pt, TransCoord.COORD_TYPE_WGS84, TransCoord.COORD_TYPE_KTM);
or let us know what the error message is :).
Titus

5 Kommentare

Youngyong Park
Youngyong Park am 25 Jul. 2016
Thanks for your answer. I have tried as you mentioned. It works without any comfile error. And when I try checking the result value of ktmpt by using ktmpt without semicoln, matlab just shows me "ktmpt =
kr.hyosang.coordinate.CoordPoint@106f29c8"
This is not what I want to get. Actually, that code is to transform Coordinate system. So result of the code should be two real values. eg)512.12 353.1234 something like this.
Malcolm Lidierth
Malcolm Lidierth am 26 Jul. 2016
ktmpt is a Java object: an instance of kr.hyosang.coordinate.CoordPoint with hashCode 106f29c8.
Extract your data using the object's methods. To get a list of them, type:
>> methods(ktmpt)
at the MATLAB prompt.
Youngyong Park
Youngyong Park am 27 Jul. 2016
Thank you, Malcolm Lidierth. Unfortunately, I am not used to using java. Even though I type 'methods(ktmpt)', I don't konw how to use it. You can download the 'jar' file on
Could you test using download file?
As Malcolm said, with methods(ktmPt) you should get a list of methods. I could imagine there are methods called getX and getY or something similar. In this case simply do
x = ktmPt.getX();
Titus
Youngyong Park
Youngyong Park am 28 Jul. 2016
Thank you, Titus Edelhofer . When I type methods(ktmPt), I get the following list:
Methods for class kr.hyosang.coordinate.CoordPoint:
CoordPoint convertCONG2BESSEL convertWGS2UTM equals wait clone convertKTM2BESSEL convertWGS2WCONG getClass convertBESSEL2CONG convertTM2BESSEL convertWGS2WKTM hashCode convertBESSEL2KTM convertUTM2WGS convertWGS2WTM notify convertBESSEL2TM convertWCONG2WGS convertWKTM2WGS notifyAll convertBESSEL2WGS convertWGS2BESSEL convertWTM2WGS toString
And I have tried all the possible cases, but I couldn't get the result I want.

Melden Sie sich an, um zu kommentieren.

Kategorien

Tags

Gefragt:

am 25 Jul. 2016

Kommentiert:

am 28 Jul. 2016

Community Treasure Hunt

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

Start Hunting!

Translated by