I built a Java application that is delivered on USB sticks. To ensure compatibility, I ship an appropriate JVM on the sticks. I mad开发者_C百科e an EXE that simply invokes this JVM with the application jar.
Now the problem: some virus scanners act aggressively and just remove the executable!
I tried an exe made with a "Batch file to Executable" tool and one written myself in C (invoking ShellExecute); both versions are detected and eliminated by Norton SONAR but I can imagine other virus scanners might react similarly.
I initially opted for a windows shortcut but these don't seem to support relative paths. A batch file is not acceptable either since I don't want the command console to be shown.
You could try using one of the many configurable java launchers - they may be less likely to be picked up by AVs:
- NSIS
- Janel
- JSmooth
- Launch4J
- WinRun4J
(full disclosure: i work on winrun4j)
Use start/b java.exe ...
in a batch file. There will be a short flicker but the window will quickly go away.
As for the virus scanner removing your file: Use a stick that has a hardware switch which can make it write protected. It's for your own safety: just because there is a virus scanner doesn't mean there is no virus. If no one can write to the stick, no one can mess with it.
If you launch your app using javaw.exe
you shouldn't have an associated console window at all so that might get round the need to convert your bat file into an .exe.
You could also consider distributing your app as a Webstart app, whereby the associated jnlp file describes the minimum required version of the JVM.
Since the program won't have to change very often: Submit it as a false-positive to the AV vendors, then it will probably be white-listed quite rapidly. Or at least you might find out what it is that they find so objectionable.
精彩评论