试图在八度中调用Java对象 [英] trying to call a Java-Object in Octave

查看:86
本文介绍了试图在八度中调用Java对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我正在尝试在Octave中调用Java对象. Javaclasspath和其他所有东西都已设置.

Hey Guys im trying to call a Java-Object in Octave. The Javaclasspath and everything else is set.

当我尝试像这样调用自己创建的函数时:

When i try to call a own created function like this:

>> x = javaObject('server_console.Server_Client')

我收到此错误:

error: [java] java.lang.ClassNotFoundException: server_console.Server_Client

但是,如果我使用基本功能,它就可以正常工作.

But if i use Basic function it works fine.

<Java object: java.lang.Float>

>> javaMethod('floatToIntBits', 'java.lang.Float', single(10.07))

ans =   1.0927e+009

推荐答案

八度音的javaclasspath

首先,再次检查.jar或.class文件是否位于Octave的Java路径中.使用以下八度命令:

Octave's javaclasspath

First, double check that the .jar or .class file is in Octave's java path. Use this Octave command:

javaclasspath

它应该输出如下内容:

   STATIC JAVA PATH

     ./path/to/your_file.jar
     ./path/to/your-other-file.class

   DYNAMIC JAVA PATH

     - empty -

如果在这里看不到.jar或.class文件,则可以将其添加到静态或动态路径中.动态路径存在已知问题,因此,我建议使用静态路径.一种方法是创建一个javaclasspath.txt.该文件的格式是每个类路径一行.示例内容:

If you don't see your .jar or .class file here, you can add it to either your static or dynamic path. There are known issues with dynamic path, so I'd recommend using the static path. One way to do that is to create a javaclasspath.txt. The format of that file is one line per classpath. Example content:

./path/to/your-file.jar
./path/to/your-other-file.class

(请确保在文件名中包含".jar"或".class".)

(Be sure to include ".jar" or ".class" in the filenames.)

在此处Octave会按以下顺序查找该文件:

Here's where Octave looks for that file, in order:

  1. 当前目录(开始Octave的位置)
  2. 用户的主目录
  3. 在与javaclasspath.m相同的文件夹中,通常类似于OCTAVE_HOME/share/octave/OCTAVE_VERSION/m/java/.

更多信息此处.

由于您的Server_Client类是server_console软件包的一部分,所以我猜您可能正在使用.jar文件.让我们确保它包装正确.运行

Since your Server_Client class is part of the server_console package, I'm guessing you might be using a .jar file. Let's make sure it's packaged correctly. Run

jar tvf path/to/your-file.jar

由于您正在尝试访问类server_console.Server_Client,因此您将希望在输出中看到类似这样的内容:

Since you're trying to access the class server_console.Server_Client, you'll want to see something like this in the output:

   0 Wed Sep 30 08:11:58 EDT 2015 server_console/
1893 Wed Sep 30 08:11:58 EDT 2015 server_console/Server_Client.class

您还可以使用以下命令测试您的.jar文件:

You can also test your .jar file with this command:

java -cp ./path/to/your-file.jar server_console.Server_Client

如果您的.jar文件未正确打包,您将看到以下输出:

If your .jar file is not packaged correctly, you'll see this output:

Error: Could not find or load main class server_console.Server_Client

如果您的.jar文件已正确打包,并且具有main方法,则将运行main方法.

If your .jar file is packaged correctly and you have a main method, the main method will be run.

如果您的.jar文件已正确打包并且没有main方法,则会看到以下输出:

If your .jar file is packaged correctly and you don't have a main method, you'll see this output:

Error: Main method not found in class server_console.Server_Client, please define the main method as:
    public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application

这篇关于试图在八度中调用Java对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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