user1669296
user1669296

Reputation: 445

How to build JAR files from

I am using ColdFusion 2016 and want to use this java library from within ColdFusion.

https://github.com/getstream/stream-java

It is not clear what folders are needed to make this work. I'm very new to doing something specifically like this so please excuse my question if isn't phrased correctly.

I tried downloading the entire zip file from github, renaming it with a .jar extension, and dropping it in my CF classpath but I couldn't seem to instantiate any of the classes.

Upvotes: 0

Views: 303

Answers (1)

SOS
SOS

Reputation: 6550

That's because they're not classes. What you downloaded are the .java source files. Sources must be compiled into *.class files before you can use them. The project is set up for Maven, so you can use an IDE like Eclipse to import the project, then run a Maven build which will compile and create the jar for you.

  1. Download and install Eclipse with JDK 1.8 or higher (not JRE version)
  2. Extract the .zip sources to a folder on disk
  3. In Eclipse, import the project sources.

    • Select File > Import > Maven > Existing Maven Projects then click Next Eclipse Project Import
      Existing Maven Project

    • Click Browse and navigate to the folder where you extracted the .zip files. Select the root folder stream-java-master and click Select Folder > FinishSelect Folder

  4. Build the jar

    • Go to Package Explorer, right click the project stream-core and select Run As > Maven Install
      Eclipse > Maven Install

    • Check the console for a success/failure message:

      [INFO] BUILD SUCCESS

    • The compiled jar will be located in a subdirectory named /target. Example:

      C:\temp\stream-java-master\stream-core\target\stream-core-2.0.2-SNAPSHOT.jar

If needed, repeat step 4 ("Build a jar") for the other 3 projects.

Upvotes: 2

Related Questions