executable-jar

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

陌路散爱 提交于 2019-11-26 11:21:18
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 met is: URI is not hierarchical . this error I don't meet when run in IDE. If I change above code as some

Executing a Jar on Vista with a double click

為{幸葍}努か 提交于 2019-11-26 09:28:44
问题 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? 回答1: 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

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

邮差的信 提交于 2019-11-26 09:27:19
问题 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

How to include SQLite database in executable Jar?

天涯浪子 提交于 2019-11-26 08:56:19
问题 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

Distributing my Python scripts as JAR files with Jython?

不问归期 提交于 2019-11-26 08:54:39
问题 I have been a Python programmer for almost two years, and I am used to writing small scripts to automate some repetitive tasks I had to do at the office. Now, apparently my colleagues noticed this, and they want those scripts too. Some of them have Macs, some Windows; I made these on windows. I investigated the possibility of using py2exe or even py2app to make natives of my script, but they never satisfied me... I came to know that all of them have JVM on their systems, so can I give them

Building a runnable jar with Maven 2

佐手、 提交于 2019-11-26 07:54:45
问题 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?

Strange behavior of Class.getResource() and ClassLoader.getResource() in executable jar

大城市里の小女人 提交于 2019-11-26 07:28:25
问题 I understand from What is the difference between Class.getResource() and ClassLoader.getResource()? and from own code, that getClass().getResource(\"/path/image.png\") is identical to getClass().getClassLoader().getResource(\"path/image.png\") The posting Cannot read an image in jar file shows an issue where using getClass().getClassLoader().getResource(\"path/image.png\") in an executable jar file returns null, while getClass().getResource(\"/path/image.png\") returns the correct URL. Since

What is the best way to deploy JavaFX application, create JAR and self-contained applications and native installers

放肆的年华 提交于 2019-11-26 06:44:19
问题 I\'m using IntelliJ IDEA, and I have my JavaFX application ready for deployment. The problem is that when I generate the JAR file, it won\'t run, when I run it in the command line, I get an Exception, FXMLLoadException, although the project is working perfectly in my IDE. Ant tasks end with errors, after 15 minutes of building, I really don\'t understand what\'s the problem exactly. So my question what are the right steps to deploy a JavaFX application the right way, any tutorial or guide

Java command line with external .jar

不羁的心 提交于 2019-11-26 06:35:58
问题 I develop a project using .jar to reuse code. So I have on .jar named TOOLS.jar, and I develop a simple application in file HelloWorld.java wich refer my package TOOLS from TOOLS.jar I compile with this command line : javac -g -d C:\\MyApp -cp TOOLS.jar HelloWorld.java It\'s successful, and when I want to execute my application I use this command (I\'m in C:\\MyApp folder) : java -cp <path>\\TOOLS.jar;. HelloWorld It\'s successful, but my question is : How do I execute my application when I

Reference jars inside a jar

China☆狼群 提交于 2019-11-26 05:26:27
问题 I have a jar whose content looks as shown below, Below is my manifest file Manifest-Version: 1.0 Ant-Version: Apache Ant 1.8.3 Created-By: 1.7.0_06-b24 (Oracle Corporation) Main-Class: org.sai.com.DerbyDemo Class-Path: derby.jar derbyclient.jar derbynet.jar derbytools.jar When i try to run the jar, it has thrown a ClassNotFoundExcception meaning it isn\'t referencing the jars inside the outer jar. In the Class-Path attribute, how can I reference jars ( derby.jar , etc) inside the actual jar?