Is there any way to process/read/write ARJ compressed file in java without extracting to some directory ?
7-zip has Java bindings for its c++ apis.
Have a look at http://commons.apache.org/compress/ if you want to stay within a JVM and not rely on native apps
Related
I have a device which I want to access from java. The only way to do this is using a dll library provided by the manufacturer. I have read about JNI, JNA etc. and maybe there is a tool outside which analyses the dll and generates the Java classes automatically.
Does anybody know a way of doing this?
You need something like this - JNAerator can "compile" native headers in order to generate JNA mappings, with some limited C++ support.
Finally we used jawin to generate the Java classes for accessing the the .dll. The jawin typebrowser tool was the only one that could handle the C++ .dll we were trying to access.
Unfortunately the jawin project is no longer developed. The last version is dated to early 2005.
I know it's possible to load a DLL (Windows library) in java.
And I know that a compiled java program runs anywhere..
Can a java program that loads a DLL run in a Unix environment ? (if the DLL file is present there)
No. A DLL runs native Windows instructions that are not compatible with a UNIX operating system. However shared libraries (.so) can be accessed using JNI.
To ensure a portable "Write once run anywhere" model, calls to native libraries should be avoided in favor of a pure Java implementation.
I would be very surprised. The DLL (provided it's native) will be built with OS and platform-specifics.
No. You can't take a Windows PE/COFF DLL and stick it in a Unix environment, it just won't work. (Unless you're talking about Cygwin/MSYS)
You will have to compile the library for the target system and use that.
It is possible to load the DLL in unix indeed. However many dlls use the windows API which is not available on UNIX. You must also check for copyright issues that you may encounter doing that. Native library access is possible using JNI. But this (loading DLL in unix) is not a supported and reliable configuration.
To give you a brief answer and a short advice: the answer is no and the advice is to not waste your time doing this.
I need to create some software which works with ZIP archives compressed with very old implode method.
Tried to write decompressor but nothing good happened. Optimized C-code is very hard for me.
Found this C-implementation (here) but cannot write it on Java. Just found request in Apache-commons about this feature (JIRA contatin link to APPNOTES.TXT with method description).
I should write cross-platform decompressor for this method.
Perfect is native-Java implementation.
Looking for help. Thanks.
Starting with the version 1.7 Apache Commons Compress can decompress imploded and shrunk zip entries. This is a pure Java implementation of the algorithm.
http://commons.apache.org/compress/
Did you try if TrueZip supports those older formats?
sevenzipjbinding - 7-Zip-JBinding is a java wrapper for 7-Zip C++ library. It allows extraction of many archive formats using a very fast native library directly from java through JNI.
We need a cross platform solution for compressing files. Our server runs on Windows XP/Vista/7 and 3 Unix distros, SunOS, HPUX, and AIX. Our server creates files that needed to be zipped before being set back to the client. Our initial thought was to compress the files with jar, as most of the servers have java installed, but apparently jar isn't included in the jre, just the jdk. Our server is written in C and the application that needs to create a compressed file is Perl.
I'd really like something I don't have install as our install base is LARGE and adding new required applications is generally difficult. Is there anything that is guaranteed to be built into each of those OSes that I could use for zipping? Even if I have to use something different for each, that would probably be okay also.
If you don't want to have to install anything you're pretty much SOL. Windows doesn't make this easy.
If you want to write something yourself java.util.zip is in the Java 2 Standard Edition (J2SE) and Perl has Archive::Zip
I do like 7-zip a lot but for situations like yours I always go to least-common denominataor: ZIP. Simple old ZIP. Most Unices and linuxes have zip and unzip. And for windows there are lots of options, including 7-zip, that can manipulate zip files. And probably the clients will have a zip client installed.
You could always consider distributing an open source compression tool or even using a compression SDK as part of your app such as 7 ZIP's
If you have Java installed (no matter JRE or JDK), you can use the pack200 and unpack200 to create and unpack the archives. Pack200 uses gzip compression which is pretty standard.
You should note that pack200 doesn't allow to compress multiple files in one archive (nature of gzip). If it's required, you can implement your own tool in pure Java that will create zip files and run anywhere with the unified command line interface (Java has built-in zip support, see some samples).
If you go that route, you can also use the native java implementation of bz2 or 7zip formats to get better compression.
How can I copy files in Java using JNI on OS X?
You shouldn't use JNI to copy files. If you are looking for performance with copying a lot of files you should take a look at the new Java NIO File Channels.
You don't need JNI to copy files. The standard J2SE libraries will handle this. For a more powerful library, see Apache Commons IO FileUtils.