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?
Use below code instead:
gradle change to: