简体   繁体   English

从GitHub项目导出可用的.jar文件

[英]Exporting usable .jar files from GitHub project

I'm rather new to java and eclipse, and I would like to get jar files from this github project: 我是java和eclipse的新手,我想从这个github项目中获取jar文件:

https://github.com/nikkiii/omegle-api-java https://github.com/nikkiii/omegle-api-java

I've tried doing so in eclipse, but I can't import the project as a java project, and (I think) for this reason I am not able to use the Export feature to obtain jar files for the project. 我试过在eclipse中这样做,但是我不能将项目作为java项目导入,并且(我认为)因为这个原因我无法使用Export功能来获取项目的jar文件。 What is the easiest/best way to go about this? 最简单/最好的方法是什么?

Thanks 谢谢

This is the easiest way, assuming you dowloaded the zip file containg the .java source files from github: 这是最简单的方法,假设您下载了包含来自github的.java源文件的zip文件:

  1. Unzip the zip file into a folder in your Eclipse workspace, say omegle-api-java-master . 将zip文件解压缩到Eclipse工作区中的文件夹中,例如omegle-api-java-master
  2. In Eclipse, select New->Java Project and name it omegle-api-java-master . 在Eclipse中,选择New-> Java Project并将其命名为omegle-api-java-master Eclipse will create a project from the source in your workspace, and set it up with a java builder. Eclipse将从工作区中的源创建项目,并使用java构建器进行设置。
  3. Import any required jars to get it to compile (for example the project page states you need https://github.com/douglascrockford/JSON-java ). 导入任何所需的jar以使其编译(例如项目页面声明您需要https://github.com/douglascrockford/JSON-java )。 You can extract that in your workspace in the same way and then import it into your Omegle project by right clicking on the Omegle project, selecting Properties , going to Java Build Path , selecting the Projects tab, and clicking the Add button. 您可以以相同的方式在工作区中提取它,然后右键单击“聊天”项目,选择“ Properties ,转到“ Java Build Path ,选择“ Projects选项卡,然后单击“ Add按钮,将其导入到您的“聊天”项目中。
  4. Once everything is compiling, right click on the Omegle project, select Export -> Java -> JAR file , which will create your jar file for you. 一切都在编译后,右键单击“聊天”项目,选择“ Export - >“ Java - >“ JAR file ,这将为您创建jar文件。

I assume that you have an Android library (downloaded a GitHub repository of the library) and found that it doesn't contain pom.xml . 我假设你有一个Android库 (下载了库的GitHub存储库),发现它不包含pom.xml If you have this file, see How to Create a jar file from github project . 如果您有此文件,请参阅如何从github项目创建jar文件

  1. Open a folder of the library and add local.properties file with a path to your Android SDK (for instance, sdk.dir=D\\:\\\\Android\\\\SDK ). 打开库的文件夹,并添加带有Android SDK路径的local.properties文件(例如, sdk.dir=D\\:\\\\Android\\\\SDK )。 Otherwise you can see an error: SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable 否则,您可以看到错误: SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable . SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable

  2. In command prompt (cmd.exe) run gradlew build . 在命令提示符(cmd.exe)中运行gradlew build If it will throw Android exceptions, maybe you should switch to master branch of the library and build again. 如果它会抛出Android异常,也许您应该切换到库的master分支并再次构建。

  3. If everything was normal see subfolders and look for build\\libs folders inside. 如果一切正常,请参阅子文件夹并在里面查找build\\libs文件夹。 There you can find jar -files. 在那里你可以找到jar文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM