Minimize an Uber Jar correctly, Using Shade-Plugin

This functionality has been added to version 1.6 of the maven-shade-plugin (just released). minimizeJar will now not remove classes that have been specifically included with filters. Note that including some of an artifact’s classes in a filter will exclude non-specified classes for that artifact, so be sure to include all the classes that you need. … Read more

How to include SQLite database in executable Jar?

What library are you using for SQLite? I did a search based on the connection URI you indicated and found this one. In the documentation it says: 2009 May 19th: sqlite-jdbc-3.6.14.1 released. This version supports “jdbc:sqlite::resource:” syntax to access read-only DB files contained in JAR archives, or external resources specified via URL, local files address … Read more

Prevent launching multiple instances of a java application

You could use a FileLock, this also works in environments where multiple users share ports: String userHome = System.getProperty(“user.home”); File file = new File(userHome, “my.lock”); try { FileChannel fc = FileChannel.open(file.toPath(), StandardOpenOption.CREATE, StandardOpenOption.WRITE); FileLock lock = fc.tryLock(); if (lock == null) { System.out.println(“another instance is running”); } } catch (IOException e) { throw new Error(e); … Read more

“Could not find the main class” error when running jar exported by Eclipse

Verify that you can start your application like that: java -cp myjarfile.jar snake.Controller I just read when I double click on it – this sounds like a configuration issue with your operating system. You’re double-clicking the file on a windows explorer window? Try to run it from a console/terminal with the command java -jar myjarfile.jar … Read more

Eclipse cannot create runnable jar – No resources selected

The problem is most likely with your run configuration. Go to your Class that contains the main(String[] args) method you wish to automatically run when the jar is called from the command line Right-click->Run As…->Application Make sure it runs to your satisfaction Now go through the export process as before, selecting the newly created launch … Read more

Strange behavior of Class.getResource() and ClassLoader.getResource() in executable jar

I thought this question was already asked and answered! What is the difference between Class.getResource() and ClassLoader.getResource()? getClass().getResource() searches relative to the .class file while getClass().getClassLoader().getResource() searches relative to the classpath root. If there’s an SSCCE here, I don’t understand why it doesn’t 1) Show the directory organization in the .jar, and… 2) Take package … Read more