Launch jar file from VBA code

女生的网名这么多〃 提交于 2019-12-12 04:21:44

问题


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

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

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


回答1:


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.

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.

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 is what you can use to run a jar in cmd.

edit at 2017-01-10

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.



来源:https://stackoverflow.com/questions/41533076/launch-jar-file-from-vba-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!