开发者

Read MSI file with Java

I have found how to read MSI files with .Net. Some of them use some libraries that come with Wix. Is there a way I read MSI data using Java. I would like to access the tables and get 开发者_StackOverflow社区text values.


MSI files are COM structured storage. http://en.wikipedia.org/wiki/COM_Structured_Storage

There are a few options. You could try to access it with something like this: http://poi.apache.org/poifs/index.html

You could use JNI to access the native MSI APIs.

Or, you could shell out to something like a vbscript. The script dumps the results you want to stdout, which you then capture and parse in your java app.


An .MSI is basically a database. If you can read an MS Access .MDB file with Java's JdbcOdbc driver, you can use the same code to open the .MSI instead and read it's tables.

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String msiFileName= "d:/java/test.msi";
String connectString = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
connectString += msiFileName.trim() + ";DriverID=22;READONLY=true}";
Connection con = DriverManager.getConnection( connectString ,"",""); 

At least in theory. :)


Can you use Windows Installer API via Java?

The API is the only supported way of manipulating MSI files. If you're using .NET or WiX, you'll either be using these functions or functions that call these.

The binary file format of MSI is undocumented and may change between versions, so trying to read/write the binary format directly is just going to give you a real headache.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜