assembly-merge-strategy issues using sbt-assembly

As for the current version 0.11.2 (2014-03-25), the way to define the merge strategy is different. This is documented here, the relevant part is: NOTE: mergeStrategy in assembly expects a function, you can’t do mergeStrategy in assembly := MergeStrategy.first The new way is (copied from the same source): mergeStrategy in assembly <<= (mergeStrategy in assembly) … Read more

Create multiple runnable Jars (with dependencies included) from a single Maven project [duplicate]

You can do it. You’ll need a separate execution for each artifact that you’re building (i.e., give each its own id but you can leave the phase as default), and you’ll need to specify the finalName and archive/manifest/mainClass for each. <build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <executions> <execution> <id>build-a</id> <configuration> <archive> <manifest> <mainClass>foobar.Aclass</mainClass> </manifest> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> … Read more

How to copy files out of the currently running jar

Since your dlls are bundeled inside your jar file you could just try to acasses them as resources using ClassLoader#getResourceAsStream and write them as binary files any where you want on the hard drive. Here is some sample code: InputStream ddlStream = <SomeClassInsideTheSameJar>.class .getClassLoader().getResourceAsStream(“some/pack/age/somelib.dll”); try (FileOutputStream fos = new FileOutputStream(“somelib.dll”);){ byte[] buf = new byte[2048]; … Read more

Run a jar File from java program

Using ProcessBuilder(java.lang.ProcessBuilder) will solve your problem. Syntax is as follows – ProcessBuilder pb = new ProcessBuilder(“java”, “-jar”, “absolute path upto jar”); Process p = pb.start(); You can redirent input/output/error to/from files as follows File commands = new File(“absolute path to inputs file”); File dirOut = new File(“absolute path to outputs file”); File dirErr = new … Read more

How to use a file in a jar as javax.net.ssl.keystore?

Still working on implementation, but I believe it is possible to load the keystore from the jar via InputStream and explicitly set the TrustStore programatically (vs setting the System properties). See the article: Setting multiple truststore on the same JVM Got it working! InputStream keystoreInput = Thread.currentThread().getContextClassLoader() .getResourceAsStream(<path in jar>/client.ks”); InputStream truststoreInput = Thread.currentThread().getContextClassLoader() .getResourceAsStream(<path … Read more

How do I create an executable fat JAR with Gradle with implementation dependencies?

You can use the following code. jar { manifest { attributes( ‘Main-Class’: ‘com.package.YourClass’ ) } from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } } Be sure to replace com.package.YourClass with the fully qualified class name containing static void main( String args[] ). This will pack the runtime dependencies. Check the docs if … Read more