问题
I have a jar file , that i need to include in my xcode project i.e. iphone project. How to do it & also please help me, then how to use it in objective-C code, as in java its used like: system.out.println("Res:"+objA.connect("",""")blahh, blahhhhh)
Thanks for ur Help!!!!!
回答1:
Java Executables such as Jar files are not supported in iOS and are unlikely to in any future distribution of iOS.
To perform the same function as you are in your aforementioned code, you would simply use the following.
NSLog(@"Res:%@%@", blahVariable, blahVariable);
回答2:
I'm assuming you are storing some kind of resource in your jar file and you want to extract it. Jars are zip files so you need an unzipper, like https://github.com/samsoffes/ssziparchive
[SSZipArchive unzipFileAtPath:path toDestination:destination];
or http://code.google.com/p/ziparchive/
ZipArchive *zip = [[ZipArchive alloc] init];
if ( [zip UnzipOpenFile:path] ) {
[zip UnzipFileTo:destination overWrite:YES];
}
[zip UnzipCloseFile];
Both use the minizip implementation. Now you need the destination path:
NSString *destination = NSTemporaryDirectory();
and the path of your jar file:
NSString* path = [[NSBundle mainBundle].resourcePath stringByAppendingPathComponent:@"archive.jar"];
来源:https://stackoverflow.com/questions/13654660/how-jar-usage-in-iphone-project