Find a jar file given the class name?

Save this as findclass.sh (or whatever), put it on your path and make it executable: #!/bin/sh find “$1” -name “*.jar” -exec sh -c ‘jar -tf {}|grep -H –label {} ‘$2” \; The first parameter is the directory to search recursively and the second parameter is a regular expression (typically just a simple class name) to … Read more

Maven – how can I add an arbitrary classpath entry to a jar?

I found that there is an easy solution for this problem. You can add a <Class-Path> element to <manifestEntries> element, and set <addClassPath>true</addClassPath> to <manifest> element. So value of <Class-Path> element is added to class-path automatically. Example: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <addDefaultImplementationEntries>true</addDefaultImplementationEntries> <addClasspath>true</addClasspath> <mainClass>your.main.Class</mainClass> </manifest> <manifestEntries> <Class-Path>../conf/</Class-Path> </manifestEntries> </archive> </configuration> </plugin>

How do I create executable Java program? [duplicate]

You can use the jar tool bundled with the SDK and create an executable version of the program. This is how it’s done. I’m posting the results from my command prompt because it’s easier, but the same should apply when using JCreator. First create your program: $cat HelloWorldSwing.java package start; import javax.swing.*; public class HelloWorldSwing … Read more

Creating Jar with Intellij 2016 – No main manifest attribute

I was stucked with the same problem with maven build. When you are creating the artifact from project structure settings (ctrl+alt+shift+S), you have to change manifest directory: <project folder>\src\main\java change java to resources <project folder>\src\main\resources I have also used the option extract to the target JAR, and it’s working well. EDIT You can find a … Read more

How to read a file from jar in Java?

If you want to read that file from inside your application use: InputStream input = getClass().getResourceAsStream(“/classpath/to/my/file”); The path starts with “/”, but that is not the path in your file-system, but in your classpath. So if your file is at the classpath “org.xml” and is called myxml.xml your path looks like “/org/xml/myxml.xml”. The InputStream reads … Read more

Finding unused jars used in an eclipse project

ClassPathHelper is a good start. It automatically identifies orphan jars and much more. The only limitation is with dependencies that are not defined in classes, e.g. in dependency injection framework configuration files. You also have other options/complements, such as: workingfrog “Relief”, which relies on the ability to deal with real objects by examining their shape, … Read more

Could not find or load main class with a Jar File

I got it working like this: TestClass.Java package classes; public class TestClass { public static void main(String[] args) { System.out.println(“Test”); } } Use javac on the command line to produce TestClass.class. Put TestClass.class in a folder classes/. MANIFEST.MF Manifest-Version: 1.0 Main-Class: classes.TestClass Then run jar cfm test.jar MANIFEST.MF classes/ Then run it as java -jar … Read more

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