Re: Single executable jar
In the past, I have unpacked the jars manually (unzipped them) and then repacked them into a fresh jar with the provided java jar tools. You might need to modify the manifest file to include the other packages into the class library, but the result would be a single jar file which you could then bundle into an executable. You do realize however, that bundling into an exe will make the app platform dependent which kind of defeats the point of java to begin with right?
I've done similar stuff with a nice app called Platypus, but I think it might be Mac only.
Re: Single executable jar
Have you ever heard about JarJar?
I think I should use the following syntax:
Code:
java-jar-1.1.jar jarjar process <rulesFile> <inJar> <outJar>
But I don't know what should be inside of the rulesFile in my case.
Would you be willing to help me with it?
Re: Single executable jar
you can add all jars to one single jars. You have to execute
Code:
jar cf new-jar-file-name old1.jar old2.jar.... (s)
Then you have to manifest the new jar file. Check this for manifest.
Re: Single executable jar
Mawrecki,
Quote:
jar umf MANIFEST.txt PhoneBook-all.jar
Well,there is a problem.Because your main class is in PhoneBook.jar ,not in PhoneBook-All.jar . Thus this way of manifest will not work.
Quote:
Error: Could not find or load main class PhoneBook
means that you didnt manifest PhoneBook.jar
Got it?
Before merging,manifest the PhoneBook.jar . Then merge all into PhoneBook-all.jar by only the first command using cf. Then I think it will work. Otherwise you may have to manifest the merged JAR too.
Re: Single executable jar
I give you more details of this process.
In PhoneBook directory I have got:
- img (directory with PNG files)
- database.db (SQLite)
- PhoneBook.java
- PDF.java
- GUI.java
- Core.java
- MANIFEST.txt
First of all, I create img.jar from img directory:
Next, compile Java code (which generates class file):
Code:
javac PhoneBook.java
Create jar file from PhoneBook.class based on MANIFEST.txt:
MANIFEST.txt
Quote:
Manifest-Version: 1.0
Main-Class: PhoneBook
Class-Path: img.jar itextpdf-5.1.3.jar qtjambi-4.7.1.jar qtjambi-win32-msvc2008-4.7.1.jar sqlitejdbc-v056.jar
<empty line>
Code:
jar cmvf MANIFEST.txt PhoneBook.jar *.class
Finally, I copy database.db file, PhoneBook.jar, img.jar and other jars (itextpdf-5.1.3.jar, qtjambi-4.7.1.jar, qtjambi-win32-msvc2008-4.7.1.jar, sqlitejdbc-v056.jar) into the new PhoneBook-bin folder. As you know PhoneBook.jar is executable and working now.
In PhoneBook-bin directory I have got:
- database.db (SQLite)
- PhoneBook.jar (executable)
- img.jar
- itextpdf-5.1.3.jar
- qtjambi-4.7.1.jar
- qtjambi-win32-msvc2008-4.7.1.jar
- sqlitejdbc-v056.jar
So, what should I do next? Finally, I want only single executable jar and database.db. I tried your methods and it doesn't work.
Re: Single executable jar
Quote:
Originally Posted by
Mawrecki
I give you more details of this process.
In
PhoneBook directory I have got:
- img (directory with PNG files)
- database.db (SQLite)
- PhoneBook.java
- PDF.java
- GUI.java
- Core.java
- MANIFEST.txt
First of all, I create img.jar from img directory:
Next, compile Java code (which generates class file):
Code:
javac PhoneBook.java
Create jar file from PhoneBook.class based on MANIFEST.txt:
MANIFEST.txt Code:
jar cmvf MANIFEST.txt PhoneBook.jar *.class
Finally, I copy database.db file, PhoneBook.jar, img.jar and other jars (itextpdf-5.1.3.jar, qtjambi-4.7.1.jar, qtjambi-win32-msvc2008-4.7.1.jar, sqlitejdbc-v056.jar) into the new PhoneBook-bin folder. As you know PhoneBook.jar is executable and working now.
In
PhoneBook-bin directory I have got:
- database.db (SQLite)
- PhoneBook.jar (executable)
- img.jar
- itextpdf-5.1.3.jar
- qtjambi-4.7.1.jar
- qtjambi-win32-msvc2008-4.7.1.jar
- sqlitejdbc-v056.jar
So, what should I do next? Finally,
I want only single executable jar and database.db. I tried your methods and it doesn't work.
Now,Try this.
Quote:
jar uf PhoneBook.jar img.jar all_jars_by_space
And try double click on PhoneBook.jar.
If it doesnt work, read this carefully,
Re: Single executable jar
Ok, it's working now!
Btw. there is another option:
1. Unzip all jar files into the same directory for example: PhoneBook
2. Add line "Main-Class: PhoneBook" into the META-INF/MANIFEST.MF file
3. Pack all files from PhoneBook directory into PhoneBook.zip
3. Rename PhoneBook.zip to PhoneBook.jar
4. Double click on PhoneBook.jar
In my idea I used 7-zip with ULTRA compression. Thanks for that my single executable jar is smaller.
Re: Single executable jar
Ok. Remark this problem as "SOLVED"