What version of javac built my jar?

A jar is merely a container. It is a file archive ā la tar or zip. While a jar may have interesting information contained within it’s META-INF hierarchy, it has no obligation to specify the vintage of the classes within its contents. For that, one must examine the class files therein. As as Peter Lawrey … Read more

What causes java.lang.IncompatibleClassChangeError?

This means that you have made some incompatible binary changes to the library without recompiling the client code. Java Language Specification §13 details all such changes, most prominently, changing non-static non-private fields/methods to be static or vice versa. Recompile the client code against the new library, and you should be good to go. UPDATE: If … Read more

How to run a JAR file

You need to specify a Main-Class in the jar file manifest. Oracle’s tutorial contains a complete demonstration, but here’s another one from scratch. You need two files: Test.java: public class Test { public static void main(String[] args) { System.out.println(“Hello world”); } } manifest.mf: Manifest-version: 1.0 Main-Class: Test Note that the text file must end with … Read more

Running JAR file on Windows

Easiest route is probably upgrading or re-installing the Java Runtime Environment (JRE). Or this: Open the Windows Explorer, from the Tools select ‘Folder Options…’ Click the File Types tab, scroll down and select JAR File type. Press the Advanced button. In the Edit File Type dialog box, select open in Actions box and click Edit… … Read more

Difference between maven scope compile and provided for JAR packaging

From the Maven Doc: compile This is the default scope, used if none is specified. Compile dependencies are available in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects. provided This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For … Read more

Reading a resource file from within jar

Rather than trying to address the resource as a File just ask the ClassLoader to return an InputStream for the resource instead via getResourceAsStream: try (InputStream in = getClass().getResourceAsStream(“/file.txt”); BufferedReader reader = new BufferedReader(new InputStreamReader(in))) { // Use resource } As long as the file.txt resource is available on the classpath then this approach will … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)