问题
I have a java program that built in netbeans that uses the RXTX from Here. So far it works very well in both windows and linux.
My question: Is it possible to include the needed RXTX files in the JAR without installing them as per the instruction on the RXTX site. I would like to be able to just give the JAR to people on Linux or Windows with all included files and have it just work.
Is that possible and what is the best way to do that?
Thank you.
回答1:
You don't need to install them per-se - all you need to do is point the java.library.path
VM argument at a folder containing the appropriate DLL files.
However, for a Jar file this will involve extracting them somewhere and then loading the DLLs separately before you initialise RXTX, since they can't be read and used from inside the Jar file directly (since it's essentially a zip archive.) The top answer on this question should point you in the right direction here (don't forget there's nothing stopping you extracting them to a temporary location and calling deleteOnExit()
on the file so it's not around longe than it has to be.)
来源:https://stackoverflow.com/questions/14596406/java-rxtx-and-packaging