jar

Creating a ClassLoader to load a JAR file from a byte array

混江龙づ霸主 提交于 2019-12-29 03:40:28
问题 I'm looking to write a custom class loader that will load a JAR file from across a custom network. In the end, all I have to work with is a byte array of the JAR file. I cannot dump the byte array onto the file system and use a URLClassLoader . My first plan was to create a JarFile object from a stream or byte array, but it only supports a File object. I've already written up something that uses a JarInputStream : public class RemoteClassLoader extends ClassLoader { private final byte[]

How to extract .war files in java? ZIP vs JAR

倖福魔咒の 提交于 2019-12-29 03:24:09
问题 I have a web program where I want the user to be able to import a .war file and I can extract certain files out of the .war file. I have found two class libraries: java.util.zip.* and java.util.jar.* . From what I understand, a WAR file is a special JAR file which is a special ZIP file. So would it be better to use java.util.jar ? If ZIP and JAR files are pretty much the same why is there a need for two different libraries? 回答1: If you look at the JarFile API you'll see that it's a subclass

Android Jar libraries

前提是你 提交于 2019-12-29 02:45:27
问题 How do you setup a project that can result in a jar library file that can be used for android? I want to create a custom library across all projects. Few other questions: Does it need to be compiled against a specific version of android sdk? When an android package is compiled against a jar library does the classes necessary to work with the code get compiled with main code into the apk or does the entire jar get included? Any notable optimizations or pitfalls I need to know about with using

Jar get image as resource

﹥>﹥吖頭↗ 提交于 2019-12-29 01:50:10
问题 I'm trying to get load an image from my jar. But no matter what string I supply for getResource() it always returns null. try { System.out.println(Bootstrapper.class.getResource("./img/logo.png").toURI().getPath()); } catch (URISyntaxException ex) { Logger.getLogger(CrawlerFrame.class.getName()).log(Level.SEVERE, null, ex); } ImageIcon ii = new ImageIcon(Bootstrapper.class.getResource("./img/logo.png")); setIconImage(ii.getImage()); Exception in thread "AWT-EventQueue-0" java.lang

Creating Java applet using external JARS

倖福魔咒の 提交于 2019-12-29 01:38:32
问题 I've created a Java Applet in Netbeans that uses several external libraries. When I run the applet.java file within Netbeans it works fine and I'm trying to get the same result in a web page. When I run the automatically created applet.html-file in the build-folder it doesn't load the external library, even though I have specified them in APPLET archive-tag and moved them to the same folder. Here is my html-file: <HTML> <HEAD> <TITLE>Applet HTML Page</TITLE> </HEAD> <BODY> <H3><HR WIDTH="100%

Android, Eclipse, Put .jar in “lib”&“add to build path” vs Put .jar in “libs”

百般思念 提交于 2019-12-29 01:28:06
问题 I was trying to add the loopj .jar library into my project, in Eclipse v3.7.2 First I added the .jar into the "lib" directory, right clicked on it and picked "add to build path". It compiles fine but when executing I get an error "Could not find class 'com.loopj.android.http.AsyncHttpClient'. So I remove the .jar from the build path, and move it into the "libs" directory. No need to add the the build path when it's in the "libs" directory, this time it compiles fine and executes fine too. So

how to add and read resource file from jar

点点圈 提交于 2019-12-29 01:24:09
问题 I have hibernate.cfg.xml and test.txt in the path which i read by java program. Now when i created the jar using maven those files were not present. So i read that i should put in the resources folder , so now my directory structure is scr -> main-> java ->resources Now i can see the files in the jar but they are not inside resource folder it bascically myjar.jar -> com (source code) -> META -INF -> hibernate.cfg.xml -> test.txt I tried accessing using getClass().getResourceAsStream("test.txt

IntelliJ GUI Designer Maven Executable JAR Export

我们两清 提交于 2019-12-28 13:59:33
问题 I'm using IntelliJ IDEA's GUI designer and Maven as build system. When I build the executable JAR file via this answer, the build succeeds. However, it throws an exception when launched via the command java -jar MyApplication.jar : Exception in thread "main" java.awt.IllegalComponentStateException: contentPane cannot be set to null. at javax.swing.JRootPane.setContentPane(JRootPane.java:621) at javax.swing.JFrame.setContentPane(JFrame.java:698) ... The affected code line is the following:

NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor conflits on Elastic Search jar

扶醉桌前 提交于 2019-12-28 13:47:26
问题 While creating Elasticsearch Client, I'm getting the exception java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor; After some lookup, seams like the Guava-18 is being overwrite by an older version at runtime, and Guava-18 only works during compile task. My Maven configuration is the follow: <build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.0</version> <configuration> <source>1.7</source

How do I include jars in a groovy script? [duplicate]

ε祈祈猫儿з 提交于 2019-12-28 07:39:27
问题 This question already has answers here : How do I auto load a database jar in Groovy without using the -cp switch? (4 answers) Closed 3 years ago . I have a groovy script that needs a library in a jar. How do I add that to the classpath? I want the script to be executable so I'm using #!/usr/bin/env groovy at the top of my script. 回答1: If you really have to you can also load a JAR at runtime with: this.getClass().classLoader.rootLoader.addURL(new File("file.jar").toURL()) 回答2: Starting a