Question

For example, the Java API for pubnub is at https://github.com/pubnub/pubnub-api/tree/master/java

I want to create a single jar file from all the java files in the subfolders.

What is the most straight-forward way to do that?

Was it helpful?

Solution

Since Pubnub provided no build file, you need to create a new java project in your favourite IDE and then import the downloaded java code. Next, you can compile and package the project into jar file using the IDE.

Note: it is also possible to create a build script yourself but it is more complicated.

OTHER TIPS

Since you want a single jar file, then the easiest way to do this is to follow the next few steps:

  1. Create a Maven project in, say NetBeans. I typically make the same name as it is on the public repository. In this case I recommend "pubnum".

  2. Pull the source from a GIT repository into the project you've created in the step #1. This part is tricky because the source in the GIT repository may not follow Maven conventions... If it does not, you must restructure it. Read about Maven directory structure.

  3. Make sure the Maven shade plugin is installed, and you are ready to roll. Just execute maven shade:shade and, if everything goes well, you'll get the jar file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top