How to run example of IProvider and Consumer applications?

I'm trying to run below commands as per the guide:


java -cp .;target/RTSDKJ_Maven-1.0-jar-with-dependencies.jar com.refinitiv.ema.provider.IProvider

java -jar ./target/RTSDKJ_Maven-1.0-jar-with-dependencies.jar


But both commands throws class not found exception. When I checked inside the jar file, I couldn't find the specific classes as well.

Can anyone help me to find how to run these commands?

Best Answer

  • wasin.w
    wasin.w admin
    Answer ✓

    Hello @hanhuitan

    If your source code directory is based on the EMA Java source code like the following example.
    ema-folder.png

    Your pom.xml setting must be matched this directory structure as follows:

      <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                            <configuration>
                                <archive>
                                    <manifest>
                                        <mainClass>
                                            com.refinitiv.ema.examples.training.consumer.series100.ex100_MP_Streaming.Consumer
                                        </mainClass>
                                    </manifest>
                                </archive>
                                <descriptorRefs>
                                    <descriptorRef>jar-with-dependencies</descriptorRef>
                                </descriptorRefs>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>

    Then you need to run the single-all-dependencies jar file with the following classpath

    java -cp .;target/RTSDKJ_Maven-1.0-jar-with-dependencies.jar com.refinitiv.ema.examples.training.iprovider.series100.ex100_MP_Streaming.IProvider


    java -jar ./target/RTSDKJ_Maven-1.0-jar-with-dependencies.jar

Answers

  • Hello @hanhuitan

    It seems the RTSDKJ_Maven-1.0-jar-with-dependencies.jar file does in included the Dependencies classes.

    How did you build the jar? I am assuming that you are using Maven, did you set Maven to build a single-all-dependencies jar file in the pom.xml file?

    You can find an example in the "Building the project" section of the How to Set Up Refinitiv Real-Time SDK Java Application with Maven article.

    Please note that the classpath in a <manifest> tag must match the source code directory.

    <project xmlns="http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
        <modelVersion>4.0.0</modelVersion>
        ...
        <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                    <configuration>
                        <archive>
                            <manifest>
                                <mainClass><Main Class></mainClass>
                            </manifest>
                        </archive>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                    </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        </build>
    </project>
  • Hello @hanhuitan

    Which version of the EMA API you are using?

    • If you want to use EMA Java 3.6.7.0 L1 --> Please specify the EMA library version "3.6.7.1" in the pom.xml dependency setting
    • If you want to use EMA Java 3.6.7.0 L2 --> Please specify the EMA library version "3.6.7.3" in the pom.xml dependency setting
    <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>4.11</version>
          <scope>test</scope>
        </dependency>
        
        <dependency>
          <groupId>com.refinitiv.ema</groupId>
          <artifactId>ema</artifactId>
          <version>${rtsdk.version}</version>
        </dependency>

    Hope this helps.

  • Hi,


    Can I get a maven example project instead of Gradle?

  • Hello @hanhuitan

    The RTSDK Java is currently available with Gradle-based by default. However, you can submit a change request to the product team via the https://my.refinitiv.com/content/mytr/en/feedback.html page.

  • Hi
    @wasin.w ,


    Could you please give me this project with maven?

  • Hello @hanhuitan

    The project above is based on the How to Set Up Refinitiv Real-Time SDK Java Application with Maven article, but you need to change the source code to the EMA Java example one.

    Another practical step-by-step guide to set up an EMA Java examples project with Maven is the How to Set Up Real-Time SDK Java Application with Maven on the Eclipse IDE article.

    As I said earlier, the RTSDK Java is available with Gradle-based by default. However, you can submit a change request to the product team via the https://my.refinitiv.com/content/mytr/en/feedback.html page.