Java 如何将jar文件转换成apk?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18889586/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 11:57:37  来源:igfitidea点击:

How to convert jar file into apk?

javaandroidjarapk

提问by Lavanya

I have one jar file, when I clicked that jar file, it was opened one window based application.

我有一个 jar 文件,当我单击该 jar 文件时,它打开了一个基于窗口的应用程序。

Now I would like to convert this jar file into apk file. That jar file having 5 class files. How can I know the initial class file? and How could I code on this in android?

现在我想把这个 jar 文件转换成 apk 文件。该 jar 文件有 5 个类文件。我怎么知道初始类文件?以及如何在 android 中对此进行编码?

Please do the needful.

请只做那些需要的。

Thanks in advance.

提前致谢。

回答by damax

You can convert J2ME apps (jar/jad) to Android (apk) using UpOnTek's conversion services. Service includes automatic conversion, followed by optimization tips.

您可以使用 UpOnTek 的转换服务将 J2ME 应用程序 (jar/jad) 转换为 Android (apk)。服务包括自动转换,后跟优化提示。

回答by Damian Ko?akowski

How can I know the initial class file?

我怎么知道初始类文件?

Please read http://docs.oracle.com/javase/tutorial/deployment/jar/appman.html.You should have a look at following part:

请阅读http://docs.oracle.com/javase/tutorial/deployment/jar/appman.html。你应该看看以下部分:

If you have an application bundled in a JAR file, you need some way to indicate which class within the JAR file is your application's entry point. You provide this information with the Main-Class header in the manifest, which has the general form:.......

如果您的应用程序捆绑在 JAR 文件中,您需要某种方式来指明 JAR 文件中的哪个类是您的应用程序的入口点。您通过清单中的 Main-Class 标头提供此信息,其一般形式为:......

Answering to your next question:

回答你的下一个问题:

How could I code on this in android?

我怎么能在android中对此进行编码?

Import JAR file to Android Project. You can get JAR's entry point from Manifest file ( not AndroidManiefst.xml but from JAR's Manifest). However, you mentioned:

将 JAR 文件导入 Android 项目。您可以从 Manifest 文件(不是 AndroidManiefst.xml,而是从 JAR 的 Manifest)获取 JAR 的入口点。但是,您提到:

it was opened one window based application.

它打开了一个基于窗口的应用程序。

It looks like those 5 classes have dependencies on some different JARs which could not be available on Android platform.

看起来这 5 个类依赖于一些在 Android 平台上无法使用的不同 JAR。