How Jar usage in iphone project?

混江龙づ霸主 提交于 2020-01-06 08:17:33

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!