6

I'm rather new to java and eclipse, and I would like to get jar files from this github project:

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. What is the easiest/best way to go about this?

Thanks

gratsby
  • 3,107
  • 4
  • 20
  • 20
  • 1
    [This post's answers and comments](http://stackoverflow.com/questions/6760115/importing-a-github-project-into-eclipse) contain links to importing projects in Eclipse directly from git hub. Otherwise, just import the project on the command line and then create an Eclipse project from the source. – eebbesen Jul 21 '13 at 03:57

2 Answers2

9

This is the easiest way, assuming you dowloaded the zip file containg the .java source files from github:

  1. Unzip the zip file into a folder in your Eclipse workspace, say omegle-api-java-master.
  2. In Eclipse, select New->Java Project and name it omegle-api-java-master. Eclipse will create a project from the source in your workspace, and set it up with a java builder.
  3. Import any required jars to get it to compile (for example the project page states you need 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.
  4. Once everything is compiling, right click on the Omegle project, select Export -> Java -> JAR file, which will create your jar file for you.
MilesHampson
  • 2,069
  • 24
  • 43
  • "Unzip the jar into a folder in your workspace, say omegle-api-java-master."... unzip which jar exactly? I'm trying to obtain the jars for the project – gratsby Jul 21 '13 at 04:06
  • I was unclear, I meant unzip the zip file that you have downloaded from github, assuming that this is how you want to get the project. I have edited my answer to clarify. – MilesHampson Jul 21 '13 at 04:10
  • Can you explain step two in a little more detail? So I put the folder in my workspace, created a new Java Project, but are you saying what's supposed to happen is the existing folder in my workspace will be turned into a Java Project? Because all I see when creating a new project is a new, empty java project, even after refreshing. – gratsby Jul 21 '13 at 04:20
  • The idea is to create an eclipse project over the top of the source you downloaded. So I have say C:\myworkspacedir\omegle-api-java-master\src\... and in eclipse when creating a new java project I create new project with location C:\myworkspacedir and with project name omegle-api-java-master, and from that I get a normal java project with a .project file containing a java builder, and with the src folder being compiled. Is that the case for you as well? Otherwise all I can think of is checking your eclipse java core is working by creating and compiling a new java project from scratch. – MilesHampson Jul 21 '13 at 04:29
  • Did you have success with this method, or did you find another way to answer this question? – MilesHampson Jul 26 '13 at 15:52
0

I assume that you have an Android library (downloaded a GitHub repository of the library) and found that it doesn't contain pom.xml. If you have this file, see How to Create a jar file from github project.

  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). 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.

  2. In command prompt (cmd.exe) run gradlew build. If it will throw Android exceptions, maybe you should switch to master branch of the library and build again.

  3. If everything was normal see subfolders and look for build\libs folders inside. There you can find jar-files.

CoolMind
  • 26,736
  • 15
  • 188
  • 224