executable-jar

Why is my URI not hierarchical? [duplicate]

心不动则不痛 提交于 2019-11-26 16:32:05
This question already has an answer here: Java Jar file: use resource errors: URI is not hierarchical 6 answers I have files in resource folder. For example if I need to get file from resource folder, I do like that: File myFile= new File(MyClass.class.getResource(/myFile.jpg).toURI()); System.out.println(MyClass.class.getResource(/myFile.jpg).getPath()); I've tested and everything works ! The path is /D:/java/projects/.../classes/X/Y/Z/myFile.jpg But , If I create jar file, using , Maven : mvn package ...and then start my app: java -jar MyJar.jar I have that following error: Exception in

Why does my JAR file execute at CMD, but not on double-click?

霸气de小男生 提交于 2019-11-26 16:25:59
问题 So I've been writing a simple 3D GUI application that I intended for users to use simply by double-clicking on the JAR file. I got it working perfectly before putting it into the JAR file, and I got it working perfectly IN the JAR file while running from command prompt (typing "java -jar Modeler.jar" while in the directory of the jar file). However, when I double-click it, nothing happens. It runs perfectly fine with no errors from command prompt. I know from experience that crash reports on

assembly-merge-strategy issues using sbt-assembly

落花浮王杯 提交于 2019-11-26 15:59:19
问题 I am trying to convert a scala project into a deployable fat jar using sbt-assembly. When I run my assembly task in sbt I am getting the following error: Merging 'org/apache/commons/logging/impl/SimpleLog.class' with strategy 'deduplicate' :assembly: deduplicate: different file contents found in the following: [error] /Users/home/.ivy2/cache/commons-logging/commons-logging/jars/commons-logging-1.1.1.jar:org/apache/commons/logging/impl/SimpleLog.class [error] /Users/home/.ivy2/cache/org.slf4j

Create multiple runnable Jars (with dependencies included) from a single Maven project [duplicate]

亡梦爱人 提交于 2019-11-26 15:59:10
问题 This question already has an answer here: Creating Two Executable Jars Using maven-assembly-plugin 1 answer I have a single maven project that has multiple main classes. I want to generate runnable Jars (that include all dependencies) out of these project. I currently have the following build configuration (using maven.assembly): <build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>classpath.to.my.mainClass</mainClass> <

Execute .jar file from a Java program

瘦欲@ 提交于 2019-11-26 15:14:31
How could I run a local jar file from a java program? The jar file is not in the class-path of the Java caller program. I suggest you use a ProcessBuilder and start a new JVM. Here is something to get you started: ProcessBuilder pb = new ProcessBuilder("/path/to/java", "-jar", "your.jar"); pb.directory(new File("preferred/working/directory")); Process p = pb.start(); Process proc = Runtime.getRuntime().exec("java -jar Validate.jar"); proc.waitFor(); // Then retreive the process output InputStream in = proc.getInputStream(); InputStream err = proc.getErrorStream(); byte b[]=new byte[in

How to copy files out of the currently running jar

瘦欲@ 提交于 2019-11-26 14:38:35
问题 I have a .jar that has two .dll files that it is dependent on. I would like to know if there is any way for me to copy these files from within the .jar to a users temp folder at runtime. here is the current code that I have (edited to just one .dll load to reduce question size): public String tempDir = System.getProperty("java.io.tmpdir"); public String workingDir = dllInstall.class.getProtectionDomain().getCodeSource().getLocation().getPath(); public boolean installDLL() throws

Double Clicking JAR file does not open Command Prompt

£可爱£侵袭症+ 提交于 2019-11-26 12:47:27
问题 I want to run a Jar file by double clicking it. Following is the only Java class file present in it. import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; public class Sysout{ public static void main(String[] args) throws IOException{ System.out.println(\"Hello World!\"); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String msg = br.readLine(); System.out.println(msg); br.read(); } } And Manifest file has Main-Class defined.

Creating Runnable Jar with external files included

ⅰ亾dé卋堺 提交于 2019-11-26 12:29:58
问题 I want to build a runnable jar in java. I need to include some of the files in the jar so that when I execute jar the files are automatically read from the java class. Hence I created a folder in the project and referred these files from the project. I created jar file following some tutorial but I could not able to include these external files in my jar file. Please let me about creating runnable jar with external files. My file struture is Test | | -------src | | | default package | | | | |

What causes “Unable to access jarfile” error?

亡梦爱人 提交于 2019-11-26 12:20:18
I want to execute my program without using an IDE. I've created a jar file and an exectuable jar file. When I double click the exe jar file, nothing happens, and when I try to use the command in cmd it gives me this: Error: Unable to access jarfile <path> I use the command: java -jar Calculator.jar How I created the jar: Right click on project folder (Calculator) Select Click on Java Folder and select "Exectuable Jar File", then select next Launch Configuration: Main - Calculator Create Export Destination Hit "Finish" and profit! Well, not really. I had encountered this issue when I had run my

Building executable jar with maven?

笑着哭i 提交于 2019-11-26 11:29:16
I am trying to generate an executable jar for a small home project called "logmanager" using maven, just like this: How can I create an executable JAR with dependencies using Maven? I added the snippet shown there to the pom.xml, and ran mvn assembly:assembly. It generates two jar files in logmanager/target: logmanager-0.1.0.jar, and logmanager-0.1.0-jar-with-dependencies.jar. I get an error when I double-click on the first jar: Could not find the main class: com.gorkwobble.logmanager.LogManager. Program will exit. A slightly different error when I double-click the jar-with-dependencies.jar: