如何在Matlab中使用用户定义的Java类? [英] How do I use user defined Java classes within Matlab?

查看:382
本文介绍了如何在Matlab中使用用户定义的Java类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了有关如何执行此操作的文档和几个网站,但是Matlab似乎没有选择我添加到动态java类路径中的类。我也没有使用正确的语法来正确构造对象。

I have read the documentation and several websites on exactly how to do this, however Matlab does not seem to pick up the classes that I have added to the dynamic java class path. Nor do I use the right syntax to correctly construct the object.

我有一个类HandDB,用于创建这种类型的对象并调用它的静态方法来连接到一个SQL数据库。该类有一个空构造函数,不带参数。该类是我在Netbeans中的一个项目中创建的包'nuffielddb'的一部分。所有文件都在我的usb棒上,这是我的E:\驱动器...

I have an class HandDB and which to create an object of this type and invoke it's static methods to connect to a SQL database. The class has an empty constructor and takes no parameters. The class is part of a package 'nuffielddb' which I made in a project within Netbeans. All the files are on my usb stick which is my E:\ drive...

我希望能够使用包中的所有类。该软件包包含在E:\ nuffielddb。

I would like to be able to use all the classes within the package. The package is contained at E:\nuffielddb.

我在Matlab中输入了以下命令:

I entered the following commands into Matlab:

javaaddpath('E:\'); 
javaclasspath;    % Output from java class path includes E:\ within dynamic path
str = java.lang.String('Test'); % Works fine
db = nuffieldbd.HandDB(); % Does not work - undefined variable or class error

有趣的是我输入'import nuffielddb。*;'和收到没有错误。

Interesting I typed 'import nuffielddb.*;' and received no error.

我错在哪里?

感谢您的帮助顺便说一下!

Thanks for your help btw!

推荐答案

啊问题解决了!从某种意义上说没有解决!我发现它实际上是我的matlab安装的一个问题,我不知道如何解决它:-(
没关系,它适用于办公室的电脑: - )

Ah problem solved! Well not solved in a sense! I found out it's actually a problem with my matlab installation and I have no idea how to fix it :-( Never mind, it works on the computers at the office :-)

这篇关于如何在Matlab中使用用户定义的Java类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆