executable-jar

Creating Runnable Jar with external files included

…衆ロ難τιáo~ 提交于 2019-11-27 02:04:38
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 | | | | | test1.java | -------FileFOlder | | | | | abc.txt I am accessing abc.txt in test1.java class. My code

“Could not find the main class” error when running jar exported by Eclipse

家住魔仙堡 提交于 2019-11-27 00:52:56
I have a java project that works perfectly fine when running it from within Eclipse. When I try to export it to either a "JAR file" or "Runnable JAR file" the .jar file is created, but when I double click on it to try to run the program it gives me an error that says "Could not find the main class: package.MainClassName. Program will exit." As I mentioned, I tried exporting to both JAR options, I specified the correct class that the main method is in, and when I look through the actual files in the .jar file everything seems to be in order -- the manifest looks something like: Manifest-Version

Executing a Jar on Vista with a double click

♀尐吖头ヾ 提交于 2019-11-27 00:41:13
This pretty much has me defeated. On XP and earlier versions of Windows you could customise Open With filetypes to include java - jar "myjar.jar", but on Vista this functionality seems to have been removed. I can of course create a .bat file to launch my application, but is it possible to make Vista execute a .jar as required? You can do it from the command line with 2 utilities. The first one, ASSOC, is used to create a file association. To verify if there is one defined for JAR type : >assoc .jar .jar=jarfile If not found then create it with : >assoc .jar=jarfile The next step is to define

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

久未见 提交于 2019-11-26 23:51:40
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 there any way by which I can specify some argument on command line to run whichever class I wish to

Intellij fat one jar artifact does not generate a working output

安稳与你 提交于 2019-11-26 23:12:53
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. 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 the future updates. 来源: https://stackoverflow.com/questions/45154862/intellij-fat-one-jar-artifact-does-not

Run a jar File from java program

会有一股神秘感。 提交于 2019-11-26 23:10:48
问题 I am trying to execute jar files from another Java program. I am using the following code : try { Runtime runtime = Runtime.getRuntime(); runtime.exec("path upto jar"); } catch (Exception ex) { JOptionPane.showMessageDialog(null, "Exception occured" + ex); } But its not working. I tried google and it gave me the examples using ProcessBuilder, but that is not working either. 回答1: Using ProcessBuilder(java.lang.ProcessBuilder) will solve your problem. Syntax is as follows - ProcessBuilder pb =

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

廉价感情. 提交于 2019-11-26 21:30:17
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.NoClassDefFoundError: org/apache/commons/logging/LogFactory at com.example.myapp.fomc.common.datagen

Building a runnable jar with Maven 2

和自甴很熟 提交于 2019-11-26 21:17:19
I'm relatively new to the Maven mantra, but I'm trying to build a command-line runnable jar with Maven. I've setup my dependencies, but when I run mvn install and attempt to run the jar, two things happen. First, no main class is found, which is correctable. When I've corrected this, I get errors on run stating that classes cannot be found. Maven is not packaging my dependency libraries inside of the jar, so I am unable to run the jar as a stand-alone application. How do I correct this? Pascal Thivent The easiest way to do this would be to create an assembly using the maven-assembly-plugin and

create a executable jar using maven and jetty

流过昼夜 提交于 2019-11-26 20:33:39
问题 I want to start my application using jetty, so I have added the dependency mentioned below. and when I run the main method Jetty starts successfully.(I am working on a struts2+spring3+ hibernate maven project, i am able to deploy it in tomcat too) Now I want to create a executable jar from a war packaging pom. So i added maven-assembly-plugin to my pom. (I tried with maven jar plug-in but it was not adding the dependencies) Sources plugins <build> <plugins> <plugin> <artifactId>maven-war

How to include SQLite database in executable Jar?

╄→尐↘猪︶ㄣ 提交于 2019-11-26 20:24:40
I have created a Swing application that uses SQLite as a local database. The database file is located in project's root directory. Project/DatabaseFile The application runs fine on Eclipse, but when I run the packaged executable Jar, I get the following error: No such table : table1 This means that the database is not reachable. When I examined the contents of the resulting JAR file, the database file was not there anymore. In the code, I've linked the database as follows: jdbc:sqlite:DatabaseFile My question is, how to include the SQLite database in the executable Jar? EDIT When I placed the