Problem instantiating a Java class

1 visualización (últimos 30 días)
John
John el 7 de Ag. de 2014
Respondida: Stefan Slonevskiy el 8 de Oct. de 2018
I want to make use of the geometry classes in java.awt.geom.* in MATLAB. I can instantiate some classes like java.awt.geom.Area .But I cannot instantiate the static inner class java.awt.geom.Point2D.Double or any of its cousins, like java.awt.Point2D.Float .
For your reference, the package I am talking about is: http://docs.oracle.com/javase/7/docs/api/java/awt/geom/package-summary.html
At first I guessed it was because the Java runtime MATLAB installs does not have a complete set of standard classes.
So I added to the classpath (of a fresh MATLAB 2014a installation), $JRE_ROOT\lib\rt.jar using 'javaaddpath,' but I am still not able to instantiate java.awt.Point2D.Double . 'javaclasspath' confirms the rt.jar archive added to the DYNAMIC class path.
Then, trying to instantiate java.awt.geom.Point2D.Double gives the following error:
a = java.awt.geom.Point2D.Double(1, 1);
The class java.awt.geom.Point2D has no property or method named 'Double'.
Any idea why? I suspect it has to do either with: 1) MATLAB using the MATLAB JRE's java.awt.geom.point2D class before it looks into my Oracle JRE's rt.jar path, or 2) some syntactical problem with instantiating a JAVA static inner class within MATLAB.
PS: I looked through the "Answers" forum for very similar questions but could not find any, so apologies in advance if a very similar question happens to have been answered.

Respuestas (1)

Stefan Slonevskiy
Stefan Slonevskiy el 8 de Oct. de 2018
Just use this form:
a = javaObject('java.awt.geom.Point2D$Double',1,1)

Categorías

Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by