trying to call a Java-Object in Octave

前端 未结 1 1043
天命终不由人
天命终不由人 2020-12-22 12:33

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:



        
相关标签:
1条回答
  • 2020-12-22 13:19

    Octave's javaclasspath

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

    javaclasspath
    

    It should output something like this:

       STATIC JAVA PATH
    
         ./path/to/your_file.jar
         ./path/to/your-other-file.class
    
       DYNAMIC JAVA PATH
    
         - empty -
    

    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
    

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

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

    1. The current directory (where Octave was started)
    2. User's home directory
    3. In the same folder as javaclasspath.m, usually something like OCTAVE_HOME/share/octave/OCTAVE_VERSION/m/java/.

    More info here.

    Debugging .jar Files

    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
    

    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
    

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

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

    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
    

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

    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
    
    0 讨论(0)
提交回复
热议问题