问题
This is probably a simple question but I'm currently working with vlcj to make a video player for a project. I have a basic player working but only when I have the VM arguement
-Djna.library.path="C:\Program Files\VideoLAN\VLC"
defined in the debug configurations window. My question is if I need to create a version of this project to run outside of Eclipse do I need to define this argument in my code or will my program run in this way without problems indefinitely?
Thanks to anyone who answers,
Jared.
回答1:
I think
System.getProperties().setProperty("jna.library.path",
"C:\\Program Files\\VideoLAN\\VLC");
should do the job in code for this particular case. -D
arguments to java
set system properties, which end up in System.getProperties()
.
回答2:
You can't set JVM arguments at runtime, if you are going to export your project you'll have to find another way to do it: this is done by wrapping the execution of your program within a script file, let it be a .bat
or .sh
so that you can invoke the java executable with your paramters set.
I'm assuming you are talking about executing the program outside Eclipse.
来源:https://stackoverflow.com/questions/10774308/how-to-implement-an-eclipse-vm-argument-in-code