What’s the best way to distribute Java applications? [closed]

There are a variety of solutions, depending on your distribution requirements. Just use a jar. This assumes that the user has the the correct java version installed, otherwise the user will get “class-file format version” exceptions. This is fine for internal distribution inside a company. Use launch4j and an installer like NSIS. This gives you … Read more

How to load Classes at runtime from a folder or JAR?

The following code loads all classes from a JAR file. It does not need to know anything about the classes. The names of the classes are extracted from the JarEntry. JarFile jarFile = new JarFile(pathToJar); Enumeration<JarEntry> e = jarFile.entries(); URL[] urls = { new URL(“jar:file:” + pathToJar+”!/”) }; URLClassLoader cl = URLClassLoader.newInstance(urls); while (e.hasMoreElements()) { … Read more

How to make a .jar out from an Android Studio project

Open build.gradle for library project Write two tasks in build.gradle — deleteJar and createJar and add rule createJar.dependsOn(deleteJar, build) The code from above: task deleteJar(type: Delete) { delete ‘libs/jars/logmanagementlib.jar’ } task createJar(type: Copy) { from(‘build/intermediates/bundles/release/’) into(‘libs/jars/’) include(‘classes.jar’) rename(‘classes.jar’, ‘logmanagementlib.jar’) } createJar.dependsOn(deleteJar, build) Expand gradle panel from right and open all tasks under yourlibrary->others. You will … Read more

Add JAR files to a Spark job – spark-submit

ClassPath: ClassPath is affected depending on what you provide. There are a couple of ways to set something on the classpath: spark.driver.extraClassPath or it’s alias –driver-class-path to set extra classpaths on the node running the driver. spark.executor.extraClassPath to set extra class path on the Worker nodes. If you want a certain JAR to be effected … Read more

Eclipse exported Runnable JAR not showing images

Works fine for me. Check what you may have different. Example 1: (resources in src) Steps: File Structure Code package com.stackoverflow.test; import java.net.URL; import javax.swing.*; // Wild carded for brevity. // Actual code imports single classes public class Main { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable(){ public void run() { URL url = … Read more