How to load a jar file at runtime [duplicate]

Reloading existing classes with existing data is likely to break things. You can load new code into new class loaders relatively easily: ClassLoader loader = URLClassLoader.newInstance( new URL[] { yourURL }, getClass().getClassLoader() ); Class<?> clazz = Class.forName(“mypackage.MyClass”, true, loader); Class<? extends Runnable> runClass = clazz.asSubclass(Runnable.class); // Avoid Class.newInstance, for it is evil. Constructor<? extends Runnable> … Read more

How to create a Jar file in Netbeans

Create a Java archive (.jar) file using NetBeans as follows: Right-click on the Project name Select Properties Click Packaging Check Build JAR after Compiling Check Compress JAR File Click OK to accept changes Right-click on a Project name Select Build or Clean and Build Clean and Build will first delete build artifacts (such as .class … Read more

How to list dependencies of a JAR

There is a new tool since JDK 8: jdeps https://wiki.openjdk.java.net/display/JDK8/Java+Dependency+Analysis+Tool jdeps is a new command-line tool added since JDK 8 for developers to use to understand the static dependencies of their applications and libraries. jdeps is a static analysis tool on the given class files

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 search for a string in JAR files

You can use zipgrep on Linux or OSX: zipgrep “BEGIN REQUEST” file.jar If you wish to search a number of jars, do find libdir -name “*.jar” -exec zipgrep “BEGIN REQUEST” ‘{}’ \; where libdir is a directory containing all jars. The command will recursively search subdirectories too. For windows, you can download cygwin and install … Read more

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