问题
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