executable-jar

How do I tell Spring Boot which main class to use for the executable jar?

北战南征 提交于 2019-11-26 04:59:25
问题 Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.0.1.RELEASE:repackage failed: Unable to find a single main class from the following candidates My project has more than one class with a main method. How do I tell the Spring Boot Maven plugin which of the classes it should use as the main class? 回答1: Add your start class in your pom: <properties> <!-- The main class to start by executing java -jar --> <start-class>com.mycorp.starter.HelloWorldApplication</start

Why is my URI not hierarchical? [duplicate]

倖福魔咒の 提交于 2019-11-26 04:25:36
问题 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 :

Pass String as params from one Java App to another

浪尽此生 提交于 2019-11-26 03:45:21
问题 I\'m trying to pass String as parameter from one Java Aplications to second as StartUp parameter for example I have Aplications that must call start another Java Aplication (just contains only JOptionPane, JDialog or simple JFrame) before System.exit(0); , there I trying to send some descriptions from closing application to another, these code is simulations what I tried that and in this form, code works correctly and displayed String into the JTextArea ... import java.io.IOException; import

Execute .jar file from a Java program

核能气质少年 提交于 2019-11-26 02:56:34
问题 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. 回答1: 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(); 回答2: Process proc = Runtime.getRuntime().exec("java -jar Validate.jar"); proc.waitFor(); // Then retreive the process

Building executable jar with maven?

为君一笑 提交于 2019-11-26 02:26:30
问题 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

Java Jar file: use resource errors: URI is not hierarchical

你离开我真会死。 提交于 2019-11-26 02:21:13
问题 I have deployed my app to jar file. When I need to copy data from one file of resource to outside of jar file, I do this code: URL resourceUrl = getClass().getResource(\"/resource/data.sav\"); File src = new File(resourceUrl.toURI()); //ERROR HERE File dst = new File(CurrentPath()+\"data.sav\"); //CurrentPath: path of jar file don\'t include jar file name FileInputStream in = new FileInputStream(src); FileOutputStream out = new FileOutputStream(dst); // some excute code here The error I have

“Invalid signature file” when attempting to run a .jar

落爺英雄遲暮 提交于 2019-11-26 01:22:47
问题 My java program is packaged in a jar file and makes use of an external jar library, bouncy castle. My code compiles fine, but running the jar leads to the following error: Exception in thread \"main\" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes I\'ve googled for over an hour searching for an explanation and found very little of value. If anyone has seen this error before and could offer some help, I would be obliged. 回答1: The solution listed here

Execute another jar in a Java program

百般思念 提交于 2019-11-26 00:47:09
问题 I had written several simple java applications named as A.jar, B.jar. Now i want to write a GUI java program so that user can press button A to execute A.jar and button B to execute B.jar. Also i want to output the run-time process detail in my GUI program. Any suggestion? 回答1: If I understand correctly it appears you want to run the jars in a separate process from inside your java GUI application. To do this you can use: // Run a java app in a separate system process Process proc = Runtime

How to get the path of a running JAR file?

十年热恋 提交于 2019-11-25 22:15:31
问题 Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. My code runs inside a JAR file, say foo.jar, and I need to know, in the code, in which folder the running foo.jar is. So, if foo.jar is in C:\\FOO\\ , I want to get that path no matter what my current working directory is. 回答1: return new File(MyClass.class.getProtectionDomain().getCodeSource()

Running JAR file on Windows

爷,独闯天下 提交于 2019-11-25 22:06:13
问题 I have a JAR file named helloworld.jar . In order to run it, I\'m executing the following command in a command-line window: java -jar helloworld.jar This works fine, but how do I execute it with double-click instead? Do I need to install any software? 回答1: Easiest route is probably upgrading or re-installing the Java Runtime Environment (JRE). Or this: Open the Windows Explorer, from the Tools select 'Folder Options...' Click the File Types tab, scroll down and select JAR File type. Press the