jar

Exporting Images with JAR in Eclipse (Java)

痴心易碎 提交于 2019-12-28 06:52:40
问题 I've been working on a little project that requires external images for display. I'm not all that familiar with how to use Eclipse and this is my first time attempting to export a completed project so I can share it with others. Right now, it seems the only way I can get my images to show up is if I assign a specific folder on my hard drive and have the image paths in the code go to that. I'm looking for a way to export the images as part of my JAR or as part of the same package so when I go

Building JAR that includes all its dependencies

与世无争的帅哥 提交于 2019-12-28 06:32:08
问题 This is probably a really fundamental question, but I'm afraid I don't know much about Java and I couldn't find the answer anywhere. I'm attempting to build an Ant library which depends on the TFS SDK. I followed the guide to setting up a project, but when I export it as a JAR and try to run a task using ANT I get the following error: java.lang.NoClassDefFoundError: /com/microsoft/tfs/core/util/TFSUser I realise I could put the TFS SDK JAR in my ANT lib folder, but if possible I'd like my JAR

SLF4J NoSuchMethodError on LocationAwareLogger

橙三吉。 提交于 2019-12-28 05:49:49
问题 This is a question that has been asked before, but unfortunately no solution seems to work for me. I am facing this exception (with abridged stack trace): java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V at org.apache.commons.logging.impl.SLF4JLocationAwareLog.debug(SLF4JLocationAwareLog.java:133) at org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager$1.getConnection

Get name of running Jar or Exe

折月煮酒 提交于 2019-12-28 04:26:28
问题 What I need to do is get the name of the running jar/exe file (it would be an EXE on windows, jar on mac/linux). I have been searching around and I can't seem to find out how. How to get name of running Jar or Exe? 回答1: Hope this can help you, I test the code and this return you the full path and the name. Maybe you want to play a little more with the code and give me some feed back. File(MyClass.class.getProtectionDomain().getCodeSource().getLocation().toURI());‌ This was found on a similar

Java Classloader - how to reference different versions of a jar

大憨熊 提交于 2019-12-28 04:01:28
问题 This is a common problem. I'm using 2 libraries A.jar and B.jar and these depend on different versions of the same jar. Let's say that at runtime I need THIS.x.x.x.jar MY.jar -> A.jar -> THIS.1.0.0.jar -> B.jar -> C.jar -> THIS.5.0.0.jar I can compile the specific jar (A.jar/B.jar) against its dependency but at runtime I've to load only 1 version. Which one? Loading only 1 dependency (the latest version) means that my code will probably throw runtime exceptions if the libraries are not

How to run a maven created jar file using just the command line

a 夏天 提交于 2019-12-28 02:42:08
问题 I need some help trying to run the following maven project using the command line: https://github.com/sarxos/webcam-capture, the webcam-capture-qrcode example is the one I'm trying to run. I have it running using an the Eciplse IDE but need to move it over to just using the command line. I have the jar's created by maven. I'm trying java -classpath ./webcam-capture/target/webcam-capture-0.3.10-SNAPSHOT.jar com.github.sarxos.webcam.WebcamQRCodeExample but I keep getting the Exception in thread

Eclipse Java; export jar, include referenced libraries, without fatjar

不羁的心 提交于 2019-12-28 02:06:10
问题 I need to export jar from my Eclipse Java project and I want to include the referenced libraries. I can't use fatjar for this, which is what everyone seems to recommend. There must be another way of doing this. Does anyone know what this is?! 回答1: The next version of Eclipse (3.5, due next June) has an option to include all necessary jars. It was introduced in 3.5M5 (thanks, basszero). Or you can try to build your project with Maven 2. Then, you can build a "fat" jar with mvn assembly

How to copy file inside jar to outside the jar?

只愿长相守 提交于 2019-12-27 12:21:47
问题 I want to copy a file from a jar. The file that I am copying is going to be copied outside the working directory. I have done some tests and all methods I try end up with 0 byte files. EDIT : I want the copying of the file to be done via a program, not manually. 回答1: First of all I want to say that some answers posted before are entirely correct, but I want to give mine, since sometimes we can't use open source libraries under the GPL, or because we are too lazy to download the jar XD or what

How to copy file inside jar to outside the jar?

前提是你 提交于 2019-12-27 12:18:09
问题 I want to copy a file from a jar. The file that I am copying is going to be copied outside the working directory. I have done some tests and all methods I try end up with 0 byte files. EDIT : I want the copying of the file to be done via a program, not manually. 回答1: First of all I want to say that some answers posted before are entirely correct, but I want to give mine, since sometimes we can't use open source libraries under the GPL, or because we are too lazy to download the jar XD or what

NoClassDefFoundError while trying to run my jar with java.exe -jar…what's wrong?

风流意气都作罢 提交于 2019-12-27 12:12:52
问题 I have an application that I'm trying to wrap into a jar for easier deployment. The application compiles and runs fine (in a Windows cmd window) when run as a set of classes reachable from the CLASSPATH. But when I jar up my classes and try to run it with java 1.6 in the same cmd window, I start getting exceptions: C:\dev\myapp\src\common\datagen>C:/apps/jdk1.6.0_07/bin/java.exe -classpath C:\myapp\libs\commons -logging-1.1.jar -server -jar DataGen.jar Exception in thread "main" java.lang