So, I'm trying to add a WorldWind map to my matlab application, WorldWind is open source and written in java. I'm trying to implement this example in Matlab to start off
/*
* Copyright (C) 2012 United States Government as represented by the Administrator of the
* National Aeronautics and Space Administration.
* All Rights Reserved.
*/
import gov.nasa.worldwind.BasicModel;
import gov.nasa.worldwind.awt.WorldWindowGLCanvas;
import javax.swing.*;
/**
* This example demonstrates the simplest possible way to create a WorldWind application.
*
* @version $Id: SimplestPossibleExample.java 1171 2013-02-11 21:45:02Z dcollins $
*/
public class SimplestPossibleExample extends JFrame
{
public SimplestPossibleExample()
{
WorldWindowGLCanvas wwd = new WorldWindowGLCanvas();
wwd.setPreferredSize(new java.awt.Dimension(1000, 800));
this.getContentPane().add(wwd, java.awt.BorderLayout.CENTER);
wwd.setModel(new BasicModel());
}
public static void main(String[] args)
{
java.awt.EventQueue.invokeLater(new Runnable()
{
public void run()
{
JFrame frame = new SimplestPossibleExample();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
});
}
}
To do this in eclipse the only thing I had to do was add worldwind.jar to my javaclasspath. So, to do this in matlab I'm trying to do this
function Plot_World_Wind()
javaaddpath('C:\Users\Nellingson\Documents\Programs\worldwind-v2.1.0\worldwind.jar')
import gov.nasa.worldwind.BasicModel;
import gov.nasa.worldwind.awt.WorldWindowGLCanvas;
import javax.swing.*
h = figure;So
jf = get(h, 'JavaFrame');
jf = jf.fHG2Client.getWindow;
wwd = gov.nasa.worldwind.awt.WorldWindowGLCanvas();
wwd.setPreferredSize(java.awt.Dimension(1000, 800));
jf.getContentPane().add(wwd, java.awt.BorderLayout.CENTER);
wwd.setModel(BasicModel());
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.pack();
jf.setVisible(true);
end
But when import gets callled, the classes inside worldwindwind.jar do not get found....
Error: File: Plot_World_Wind.m Line: 4 Column: 12
Arguments to IMPORT must either end with ".*" or else specify a fully qualified class name: "gov.nasa.worldwind.awt.WorldWindowGLCanvas" fails this
test.
I double chaecked to see that they are acutally inside that jar file. Then ran javap to ensure that the jar file was not compiled with a version of java that is too new.
javap -classpath worldwind.jar -verbose gov.nasa.worldwind.awt.WorldWindowGLCanvas | findstr major
major version: 52
Which I believe is the same version matlab 2018a uses. Im completely new to calling java from matlab. I have only used it by following examples pretty closely. Here I'm guessing there is something very obvious that I'm missing. After loading worldwind.jar I checked my known classes like this...
[~,knownjavaclasses,~] = cellfun(@fileparts,[javaclasspath('-dynamic'); javaclasspath('-static')],'uniformoutput',false)
ant the ones I'm looking for arn't there. Any ideas of what to try?
2 Comments
Direct link to this comment
https://la.mathworks.com/matlabcentral/answers/430322-trouble-with-javaaddpath-for-a-jar-it-seems-to-load-fine-but-matlab-can-t-find-classes-inside#comment_638509
Direct link to this comment
https://la.mathworks.com/matlabcentral/answers/430322-trouble-with-javaaddpath-for-a-jar-it-seems-to-load-fine-but-matlab-can-t-find-classes-inside#comment_638509
Direct link to this comment
https://la.mathworks.com/matlabcentral/answers/430322-trouble-with-javaaddpath-for-a-jar-it-seems-to-load-fine-but-matlab-can-t-find-classes-inside#comment_1161098
Direct link to this comment
https://la.mathworks.com/matlabcentral/answers/430322-trouble-with-javaaddpath-for-a-jar-it-seems-to-load-fine-but-matlab-can-t-find-classes-inside#comment_1161098
Sign in to comment.