java ice4j conflict with nist-sdp package

131 views Asked by At

In my project, below code sample works without ice4j package:

import javax.sdp.*;
public class Hello 
{
    public static void main(String[] args) throws Throwable
    {
        SdpFactory factory = SdpFactory.getInstance();
    }

}

But if I include ice4j package as below:

apply plugin: 'java-library'

repositories {
    google()
    jcenter()
}
jar {
    manifest {
        attributes 'Main-Class': 'Hello'
    }
    from {
        configurations.compile.collect{it.isDirectory()?it:zipTree(it)}
    }
}
dependencies {
    compile group: 'javax.sdp', name: 'nist-sdp', version: '1.0'
    compile group: 'org.jitsi', name: 'ice4j', version: '1.0'
}

sourceCompatibility = "7"
targetCompatibility = "7"

Add ice4j package in gradle, then build no problem but if run with below command:

java -jar build/libs/Hello.jar

Error message reported:

Exception in thread "main" java.lang.NoSuchMethodError: javax.sdp.SdpFactory.getInstance()Ljavax/sdp/SdpFactory;
    at Hello.main(Hello.java:7)

Why compile passed by runtime can not find method?

1

There are 1 answers

0
AudioBubble On

Use below code instead:

SdpFactory factory = new NistSdpFactory();//SdpFactory.getInstance();

gradle change to:

compile group: 'org.opentelecoms.sdp', name: 'java-sdp-nist-bridge', version: '1.1'