简体   繁体   English

Matlab Java接口-无法将用户定义的类添加到Java类路径

[英]matlab java interface--can not add the user-defined class to the Java class path

I coded a simple class: test and compiled it and put it in th 我编写了一个简单的类:测试并编译并将其放入

'D:\Dropbox\projects\ICPR2013\code\java\union_find'. 

Code:- 码:-

public class test {
    public test() {
        System.out.printf("hello world!");
    }
}

And then I use the following code to bring the defined class to the Java class path. 然后,我使用以下代码将已定义的类带到Java类路径。 I also use javaclasspath to make sure that the folder including 'test' class is added to the Java class path. 我还使用javaclasspath来确保将包含“ test”类的文件夹添加到Java类路径。

javaaddpath('D:\Dropbox\projects\ICPR2013\code\java\union_find');

But when I use x = javaObjectEDT('test'); 但是当我使用x = javaObjectEDT('test'); to call the 'test' class, it gives me the following error: No class test can be located on Java class path 调用“测试”类,它给我以下错误:Java类路径上找不到类测试

Assuming your class is in the file called test.java, on Ubuntu 14.04 and Matlab 2013a, you can do as follows: 假设您的类位于Ubuntu 14.04和Matlab 2013a上名为test.java的文件中,则可以执行以下操作:

  1. Compile your class file using java 6 (ie java version used in Matlab 2013a). 使用Java 6(即Matlab 2013a中使用的Java版本)编译您的类文件。 Ubuntu 14.04 does not come with this java version. Ubuntu 14.04不附带此Java版本。 So you need to install it. 因此,您需要安装它。 Instructions are here . 说明在这里

    /usr/lib/jvm/java-6-oracle/bin/javac -d . / usr / lib / jvm / java-6-oracle / bin / javac -d test.java test.java

  2. Make jar file: 制作jar文件:

    /usr/lib/jvm/java-6-oracle/bin/jar cf test.jar test.class / usr / lib / jvm / java-6-oracle / bin / jar cf test.jar test.class

  3. Go to Matlab and add the jar file and run it: 转到Matlab并添加jar文件并运行它:

    javaaddpath('/tmp/test.jar'); javaaddpath( '/ TMP / Test.jar的');
    test() 测试()
    hello world! 你好,世界!

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Java TreeMap 中用户定义的 class 个对象 - User-defined class objects in Java TreeMap 有没有办法在java中制作用户定义的类类型的数组? - Is there a way to make an array of a user-defined class type in java? 使用Eclipse的用户定义Java类导入问题 - User-defined Java class import problem using Eclipse 使用Java中的最终值将ArrayList项目添加到用户定义的类中 - Adding ArrayList items to a user-defined class with final values in Java 我如何使用“对象类”在java中调用用户定义类的方法 - how can I Use of "Object Class" to call methods of user-defined classes in java Java:加载用户定义的接口实现(来自配置文件) - Java: load User-defined interface implementation (from config file) 从用户定义的文件路径(Java)访问外部资源 - Accessing external resources from a user-defined file path (Java) 如何在Java的Web项目中找到用户定义的配置文件(xml)的路径 - How can I find the path of a user-defined configure file (xml) in a web project of Java 使用 @Aspect 类型 ZA2F2ED4F8EBC04ABBB4C21A2D9 中的 java 反射访问用户定义的 object state - Access user-defined object state using java reflection in @Aspect type class JBOSS 7 EAP中属于用户定义的jar的类的java.lang.NoClassDefFoundError - java.lang.NoClassDefFoundError for class belonging to user-defined jar in JBOSS 7 EAP
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM