如何使用系统在Octave中调用.jar?

时间:2019-06-06 16:14:24

标签: java octave

我正在运行Windows 10 x64,Octave 5.1.0 x64和最新的JRE。我想从Octave中使用tabula的命令行版本:

system(['java -jar c:\ path \ to \ tabula \ tabula.jar -format JSON -lattice -t -u -p 1-3“ input.pdf”']);

此代码无法运行,并立即引发错误。当我删除这些选项时,它似乎至少开始运行,但是却给出了另一组错误。所以我认为我至少有两个问题,其中之一是我调用期权的方式。

system(['java -jar "c:\path\to\tabula\tabula.jar" "input.pdf"']);

我尝试包括不带连字符,单连字符,双连字符的选项,并且尝试用单引号和双引号定义字符串(带有适当的转义符)。当命令行与jar和pdf都位于同一文件夹中时,我还尝试了文件的完整路径以及文件名。

如果包含选项,则会出现以下错误:

2019-06-06 12:11:35.497:INFO::main: Logging initialized @459ms
2019-06-06 12:11:35.502:INFO:oejr.Runner:main: Runner
ERROR: Context 'file:/C:/path/to/jar/but/not.jar/itself/format' does not exist
Usage: java [-Djetty.home=dir] -jar jetty-runner.jar [--help|--version] [ server opts] [[ context opts] context ...]
Server opts:
 --version                           - display version and exit
 --log file                          - request log filename (with optional 'yyyy_mm_dd' wildcard
 --out file                          - info/warn/debug log filename (with optional 'yyyy_mm_dd' wildcard
 --host name|ip                      - interface to listen on (default is all interfaces)
 --port n                            - port to listen on (default 8080)
 --stop-port n                       - port to listen for stop command
 --stop-key n                        - security string for stop command (required if --stop-port is present)
 [--jar file]*n                      - each tuple specifies an extra jar to be added to the classloader
 [--lib dir]*n                       - each tuple specifies an extra directory of jars to be added to the classloader
 [--classes dir]*n                   - each tuple specifies an extra directory of classes to be added to the classloader
 --stats [unsecure|realm.properties] - enable stats gathering servlet context
 [--config file]*n                   - each tuple specifies the name of a jetty xml config file to apply (in the order defined)
Context opts:
 [[--path /path] context]*n          - WAR file, web app dir or context xml file, optionally with a context path
ERROR: java.lang.NullPointerException


I get the following errors if I don't include options:


2019-06-06 12:39:05.288:INFO::main: Logging initialized @474ms
2019-06-06 12:39:05.294:INFO:oejr.Runner:main: Runner
2019-06-06 12:39:05.420:INFO:oejs.Server:main: jetty-9.2.9.v20150224
2019-06-06 12:39:23.272:WARN:oeja.AnnotationConfiguration:main: ServletContainerInitializers: detected. Class hierarchy: empty
INFO: jruby 9.1.15.0 (2.3.3) 2017-12-07 929fde8 Java HotSpot(TM) 64-Bit Server VM 25.211-b12 on 1.8.0_211-b12 +jit [mswin32-x86_64]
INFO: using a shared (threadsafe!) runtime
2019-06-06 12:39:32.319:INFO:oejsh.ContextHandler:main: Started o.e.j.w.WebAppContext@2ff5659e{/,file:/C:/Users/ned/AppData/Local/Temp/jetty-0.0.
0.0-8080-tabula121.jar-_-any-3946933838247600913.dir/webapp/,AVAILABLE}{file:/C:/Users/path/to/tabula/tabula121.jar}
2019-06-06 12:39:32.386:WARN:oeja.AnnotationConfiguration:main: ServletContainerInitializers: detected. Class hierarchy: empty
2019-06-06 12:39:32.450:INFO:oejsh.ContextHandler:main: Started o.e.j.w.WebAppContext@77afea7d{/,file:/C:/Users/ned/AppData/Local/Temp/jetty-0.0.
0.0-8080-input.pdf-_-any-1670794067818399886.dir/webapp/,AVAILABLE}{file:/D:/path/to/input.pdf}
2019-06-06 12:39:32.451:WARN:oejsh.RequestLogHandler:main: !RequestLog
2019-06-06 12:39:32.460:WARN:oejuc.AbstractLifeCycle:main: FAILED ServerConnector@3ad847f8{HTTP/1.1}{0.0.0.0:8080}: java.net.BindException: Addre
ss already in use: bind
java.net.BindException: Address already in use: bind
        at sun.nio.ch.Net.bind0(Native Method)
        at sun.nio.ch.Net.bind(Unknown Source)
        at sun.nio.ch.Net.bind(Unknown Source)
        at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
        at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
        at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:321)
        at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
        at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:236)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.server.Server.doStart(Server.java:366)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.runner.Runner.run(Runner.java:509)
        at org.eclipse.jetty.runner.Runner.main(Runner.java:557)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at WarMain.launchWebServer(WarMain.java:187)
        at WarMain.start(WarMain.java:345)
        at JarMain.doStart(JarMain.java:233)
        at WarMain.main(WarMain.java:367)
2019-06-06 12:39:32.461:WARN:oejuc.AbstractLifeCycle:main: FAILED org.eclipse.jetty.server.Server@224aed64: java.net.BindException: Address alrea
dy in use: bind
java.net.BindException: Address already in use: bind
        at sun.nio.ch.Net.bind0(Native Method)
        at sun.nio.ch.Net.bind(Unknown Source)
        at sun.nio.ch.Net.bind(Unknown Source)
        at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
        at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
        at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:321)
        at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
        at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:236)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.server.Server.doStart(Server.java:366)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.runner.Runner.run(Runner.java:509)
        at org.eclipse.jetty.runner.Runner.main(Runner.java:557)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at WarMain.launchWebServer(WarMain.java:187)
        at WarMain.start(WarMain.java:345)
        at JarMain.doStart(JarMain.java:233)
        at WarMain.main(WarMain.java:367)
java.net.BindException: Address already in use: bind
        at sun.nio.ch.Net.bind0(Native Method)
        at sun.nio.ch.Net.bind(Unknown Source)
        at sun.nio.ch.Net.bind(Unknown Source)
        at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
        at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
        at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:321)
        at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
        at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:236)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.server.Server.doStart(Server.java:366)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.runner.Runner.run(Runner.java:509)
        at org.eclipse.jetty.runner.Runner.main(Runner.java:557)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at WarMain.launchWebServer(WarMain.java:187)
        at WarMain.start(WarMain.java:345)
        at JarMain.doStart(JarMain.java:233)
        at WarMain.main(WarMain.java:367)
Usage: java [-Djetty.home=dir] -jar jetty-runner.jar [--help|--version] [ server opts] [[ context opts] context ...]
Server opts:
 --version                           - display version and exit
 --log file                          - request log filename (with optional 'yyyy_mm_dd' wildcard
 --out file                          - info/warn/debug log filename (with optional 'yyyy_mm_dd' wildcard
 --host name|ip                      - interface to listen on (default is all interfaces)
 --port n                            - port to listen on (default 8080)
 --stop-port n                       - port to listen for stop command
 --stop-key n                        - security string for stop command (required if --stop-port is present)
 [--jar file]*n                      - each tuple specifies an extra jar to be added to the classloader
 [--lib dir]*n                       - each tuple specifies an extra directory of jars to be added to the classloader
 [--classes dir]*n                   - each tuple specifies an extra directory of classes to be added to the classloader
 --stats [unsecure|realm.properties] - enable stats gathering servlet context
 [--config file]*n                   - each tuple specifies the name of a jetty xml config file to apply (in the order defined)
Context opts:
 [[--path /path] context]*n          - WAR file, web app dir or context xml file, optionally with a context path
ERROR: java.lang.NullPointerException


In Octave I have put the path to tabula on the javaclasspath.  When I type "javaclasspath" in Octave, I get:

    STATIC JAVA PATH
      C:\correct\path\to\tabula.jar

This is driving me crazy.  Thanks so much for your help!

1 个答案:

答案 0 :(得分:1)

好吧,我知道了。我缩短了.jar文件名,因为它真的很长。众所周知,这是不允许的。那是浪费时间的错误。我恢复了原始文件名,所有系统都运行了。希望本文能对其他人有所帮助。永远不要更改.jar文件名!感谢大家给我一些时间。