how to check the version of jar file?
Decompress the JAR file and look for the manifest file (META-INF\MANIFEST.MF). The manifest file of JAR file might contain a version number (but not always a version is specified).
Decompress the JAR file and look for the manifest file (META-INF\MANIFEST.MF). The manifest file of JAR file might contain a version number (but not always a version is specified).
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
The easiest way to do this would be to create an assembly using the maven-assembly-plugin and the predefined jar-with-dependencies descriptor. You’ll also need to generate a manifest with a main-class entry for this uber jar. The snippet below shows how to configure the assembly plugin to do so: <build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> … Read more
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
Here’s what you should do instead: Put that file back in your jar file. Use class.getResourceAsStream() to read it instead of File and FileReader. Here is an explanation of how to do that: How to really read text file from classpath in Java
<build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>fully.qualified.MainClass</mainClass> </manifest> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> </plugin> </plugins> </build> and you run it with mvn clean compile assembly:single Compile goal should be added before assembly:single or otherwise the code on your own project is not included. See more details in comments. Commonly this goal is tied to … Read more
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
You can create your jar without Main-Class in its Manifest file. Then : java -cp MyJar.jar com.mycomp.myproj.dir2.MainClass2 /home/myhome/datasource.properties /home/myhome/input.txt
Add your start class in your pom: <properties> <!– The main class to start by executing java -jar –> <start-class>com.mycorp.starter.HelloWorldApplication</start-class> </properties> or <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <mainClass>com.mycorp.starter.HelloWorldApplication</mainClass> </configuration> </plugin> </plugins> </build>
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