从VBA代码启动jar文件 [英] Launch jar file from VBA code

查看:303
本文介绍了从VBA代码启动jar文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.jar文件,它从SQLite DB加载到某个字段以显示在框架中.

I have a .jar file that it load from SQLite DB some field to show in the frame.

如果我通过双击手动运行.jar很好,但是如果我使用以下VBA代码运行文件:

If I run the .jar manually with double click all is fine, but if I run the file with this VBA code:

Private Sub Comando8_Click()

   Set WshShell = CreateObject("WScript.Shell")
   strDocuments = WshShell.SpecialFolders("MyDocuments")
   FileName = "\HotelFiller\HotelFiller.jar /foo"
   strDocuments = strDocuments + FileName

   WshShell.Run strDocuments

End Sub

程序运行,但不从SQLite DB加载该字段.我在哪里错了?

The program run but don't load the field from SQLite DB. Where am I wrong?

推荐答案

jar不是exe.当您双击一个jar文件时,它可以工作.就像您单击txt文件一样,记事本将执行并读取txt文件,显示内容.

jar is not exe. when you double click a jar file, it works. Just like you click on a txt file, notepad will execute and read the txt file, show the content.

jar文件也是如此.双击jar文件时,系统(我想是Windows)将启动java.exe,java.exe将启动jar文件并从jar中执行代码.

So does jar file. When you double click the jar file, system(Windows I suppose) will launch java.exe, java.exe will launch the jar file and execute the code from jar.

我不是VB专家.但是您可以尝试将FileName = "\HotelFiller\HotelFiller.jar /foo"替换为FileName = "java -jar \HotelFiller\HotelFiller.jar /foo"

I am not an expert of VB. But you can try to replace FileName = "\HotelFiller\HotelFiller.jar /foo" with FileName = "java -jar \HotelFiller\HotelFiller.jar /foo"

java -jar xxx.jar是可用于在cmd中运行jar的东西.

java -jar xxx.jar is what you can use to run a jar in cmd.

看看您的VB代码.我想在jar中,使用System.out.println输出结果?您需要找到一种方法来启动执行java -jar \HotelFiller\HotelFiller.jar /foo"的进程.并从标准输出中获取输出.您使用它的方式似乎是一个文字字符串分配.

Take a look at your VB code. I suppose in the jar, the result is outputted using System.out.println? You need to find a way to launch a process to execute java -jar \HotelFiller\HotelFiller.jar /foo". And get the output from standard output. The way your are using it seems like a literal string assignment.

这篇关于从VBA代码启动jar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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