executable-jar

How to run TestNG tests from main() in an executable jar?

爱⌒轻易说出口 提交于 2019-12-17 19:26:14
问题 I have an executable JAR which contains all dependencies and test classes. I've confirmed that the main() method is called when I execute the jar. I'm trying to add code to main() so that I can run a specific TestNG test class. From the documentation on TestNG.org this appears to be the way to do it: TestListenerAdapter tla = new TestListenerAdapter(); TestNG testng = new TestNG(); testng.setTestClasses(new Class[] { com.some.path.tests.MyTests.class }); testng.addListener(tla); testng.run();

How to package opencv +java in a jar

自古美人都是妖i 提交于 2019-12-17 19:23:39
问题 I've been using Opencv 2.4.5 with Java for a while building an application and would now like to distribute the app. The library is loaded using the following: static{ System.loadLibrary("opencv_java245"); } which works fine. However, when exporting, it doesn't work when running from the jar: java -jar build1.jar The opencv_java245.jar file is included as a user library, with a native file (libopencv_java245.dylib) connected to it. When running the executable jar generated from Eclipse, I get

Generating a Jar in Eclipse including external library

允我心安 提交于 2019-12-17 16:49:31
问题 I have a java application I've written in eclipse. It works fine there. It works fine run from a command line in the directory where I export it to. In that directory is another directory containing two jar files that I need for the application, and the manifest file has a Class-path option specifying them. I want a way to use eclipse to generate the necessary file(s) to package this application to run on another machine. Is that possible? If I choose "create executable jar file", it creates

Prevent launching multiple instances of a java application

落花浮王杯 提交于 2019-12-17 10:57:37
问题 I want to prevent the user from running my java application multiple times in parallel. To prevent this, I have created a lock file when am opening the application, and delete the lock file when closing the application. When the application is running, you can not open an another instance of jar. However, if you kill the application through task manager, the window closing event in the application is not triggered and the lock file is not deleted. How can I make sure the lock file method

How to use a file in a jar as javax.net.ssl.keystore?

前提是你 提交于 2019-12-17 10:43:06
问题 I'm trying to do something like URL clientks = com.messaging.SubscriptionManager.class.getResource( "client.ks" ); String path = clientks.toURI().getPath(); System.setProperty( "javax.net.ssl.keyStore", path); Where client.ks is a file stored in com/messaging in the jar file that I'm running. The thing that reads the javax.net.ssl.keyStore is expecting a path to the client.ks file which is in the jar. I'd rather not extract the file and put in on the client's machine if possible. So is it

How to run a class from Jar which is not the Main-Class in its Manifest file

▼魔方 西西 提交于 2019-12-17 06:23:13
问题 I have a JAR with 4 classes, each one has Main method. I want to be able to run each one of those as per the need. I am trying to run it from command-line on Linux box. E.g. The name of my JAR is MyJar.jar It has directory structure for the main classes as follows: com/mycomp/myproj/dir1/MainClass1.class com/mycomp/myproj/dir2/MainClass2.class com/mycomp/myproj/dir3/MainClass3.class com/mycomp/myproj/dir4/MainClass4.class I know that I can specify one class as main in my Manifest file. But is

Intellij fat one jar artifact does not generate a working output

China☆狼群 提交于 2019-12-17 06:18:12
问题 Intellij fat one jar artifact does not generate a working output. Below you can see my settings and project structure( left ). When i click build artifact and then the generated output, nothing happens. 回答1: mssql-jdbc-6.2.0.jre8.jar has the digital signature ( MSFTSIG.RSA and MSFTSIG.SF files). When the jar is repackaged, the signature becomes broken. If you remove these files from the jar (either original one or the artifact), it should start fine. Vote for this issue to get it addressed in

Run java jar file on a server as background process

久未见 提交于 2019-12-17 03:23:05
问题 I need to run a java jar in server in order to communicate between two applications. I have written two shell scripts to run it, but once I start up that script I can't shut down / terminate the process. If I press ctrl + C or close the console, the server will shut down. Could anyone help me how to modify this script to run as a normal server? #!/bin/sh java -jar /web/server.jar echo $! #> startupApp.pid 回答1: You can try this: #!/bin/sh nohup java -jar /web/server.jar & The & symbol,

What causes “Unable to access jarfile” error?

本小妞迷上赌 提交于 2019-12-17 02:30:09
问题 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

create executable war maven jetty

血红的双手。 提交于 2019-12-13 19:18:58
问题 I want to create an executable war using maven jetty ,I have followed this tutorial created a main class with default package and added maven-war-plugin , maven-antrun-plugin , maven-dependency-plugin in pom.xml main class Server server = new Server(); SelectChannelConnector connector = new SelectChannelConnector(); connector.setPort(8080); server.addConnector(connector); ProtectionDomain domain = StartAppDCA.class.getProtectionDomain(); URL location = domain.getCodeSource().getLocation();