Using JarOutputStream To Create A Runnable Jar File
Apr 26, 2014
How does one use java.util.jar.JarOutputStream to create a jar file on button press? This new jar file, I want to make it runnable so it performs a specific action on run..
My app uses docx4J, XStream, and also uses an image on the start page. I placed all of this external libraries in Java Buid Path and in Eclipse it all works well but when I export all data to runnable jar file it doesn't work.
I am working on a project that requires me to build a database with random access file, representing products, the base product contains a name (about 30 characters), a price (double), and a quantity (integer). I have worked on this project for probably 15+ hours and have tried so many things and feel like I've barley made any progress...
The part i am really struggling with is taking the data from the text file and creating an object array with it using the product class. Once ive accomplished that, i have to use that data to create a random access file with the data. Here is the base Product class that must be used to create the objects for the array.
public class Product { public String pName; public String stringName; public double price; public int quanity;
[Code]...
these continue for about 40-50 entries, they are not seperated by a blank line though i had to add those so it would display correctly, each entry is on its own line with name seperated with spaces, then price after a comma, then quanity after the second comma.....
is my current exercise.so far i have gotten the code to create a file, and ask the user to input their age.what should i use to save what the user writes into the file?
Java Code:
package assignment7; import java.io.*; import java.util.*; public class Exercise2 { public static void main ( String [ ] args ) throws IOException { Scanner scan = new Scanner(System.in);
I am new to java and I am creating a system that will ask the user to create a file that will store to a text file, Once the user created the file I have a class that will let the user input the subject name that has been created, However, I keep on getting this java.util.nosuchelementexception.Here's my code:
public void display_by_name() { String id, name,total; String key[]=new String[30]; String value[]=new String[30]; int i=0;
Well my code is supposed to ask for an input file and then (ex: input.txt), read the input file and create an output.txt file with the anagram for the words in the file. Also it should be displayed on the screen. However my code doesn't display the anagram on screen or the output file!
/* This program will read a file given by the user, read the words within the file and determine anagrams of the given words. If the file that the user inputs is empty, then the program will output "The input file is empty." * The program will read the file line by line, counting the total number of words read. If there are more than 50 words, "There are more than 50 words." * will be printed, and the program will terminate. After each line is read, the words in the line will be separated,punctuation characters will be removed, and upper case characters will be switched to lower case. * If any word is larger than 12 characters, that word will not be considered in the total amount of words in the file and it will not be sorted. * After each word is read, the letters will be sorted and stored into an array containing each * word's 'signature'. After all the words have been read, words will be printed to the output file on the same line based upon their signature. */
public class Anagram { //Creating constants for maximum words in file and maximum chars in word public static final int MAX_CHARS = 12; public static final int MAX_WORDS = 50;
I am still working on my java course and now we have to create a jar file from a previous project (this is a project where a connection to the database is made and data is shown in a frame).
When I follow the instruction in my course material I don't get it to work. I've tried the following:
1. Open eclipse on windows xp 2. Right click on the project folder in eclipse 3. Click on "export" in the menu that appears 4. Choose "runnable jar" 5. click next 6. I insert the following parameters:
- Launch configuration --> I select my main class - export destination --> I select the folder D: - library handling --> Package required libraries into generated jar
7. click Finish
This is what happens when I dbl click the jarfile (wampserver is running):
1. I get an error: "SQL ERROR: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server."
2. I click ok on the message and the following message appears: "SQL Error: null"
3. I click ok on this message and the frame with the fields appears without data from the database.
my aim is to make a runnable jar. I've made a program using swings which uses MS Access database to fetch records. So, I've used an absolute path to refer to the database for connection. Now, I intend to distribute this runnable jar to other people as well. So I guess the best option would be to embed the MS Access database as well in the jar file. But I don't know how to do that. Where should I keep the database in my Project Explorer ? Should I use a relative path etc.
I've seen examples that don't use a separate Runnable Implementation, but Instead Just make a subclass of Thread and override the Thread's runO method. That way,you call the Thread's no--arg constructor when you make the new thread;
Thread t = new Thread(); 1/no Runnable"
Any simple code that demonstrates the same. I haven't fully understood what is said in the text above. I have a hunch that the last line is wrong and it should be Thread t = new <Whatever class extends Thread class and over rides its run method>()
I want to have two threads running in my class, one will be downloading info from a website then putting the thread to sleep for a little bit, then repeating. The other will be sending information to a website then putting the thread to sleep for a little bit, then repeating. Is it possible to do this in my main class? I already have one thread using run() for downloading the info and sleeping can i make another?
I recently started working with Java 8. I have been doing Java development on and off since the early 1990's. Most recently I have been doing all my current work in Java 6. I decided to "take the plunge" and to start getting involved with Java 8. I have an imaging application for geologic research I started working on in Java 6 and Swing, and I am now continuing that development under Java 8. It was a pleasant surprise that to find that all of my code built without any changes (I'm using Eclipse Luna and just deleted the Java 6 runtime and added the Java 8 runtime after downloading it). The application launches fine from inside Eclipse.
However I ran into a problem when exporting the application from Eclipse to a runnable JAR file and then trying to launch it. After creating the runnable JAR I was not able to launch it by simply double clicking. A command line box would open for a second, then close and the application window would never open. To upgrade from Java 6 to Java 8 I only downloaded the Java 8 runtime environment, not the Java 8 JDK. I am working in Windows 7 and tried updating the JAR file associations and experimented with various path entries in my environment variables. No mater what I did I could not simply double click the runnable JAR to launch it.
Then I deleted all my Java downloads and started over. This time all I did was downloaded the Java 8 JDK and installed it. I then pointed Eclipse to the Java 8 runtime environment that was installed with the Java 8 JDK. My code built and executed perfectly in the Eclipse environment. Then I exported the the Eclipse project as a runnable JAR again and tried to launch it. This time it worked as expected. Double clicking the runnable JAR launched the application!
So my question is if I want to give this application to someone to run (i.e. deploy it) that is not a developer, do I have to have them install the Java 8 JDK? I assumed that all someone would need to run the application as a runnable JAR is the Java 8 runtime environment, not the JDK. However, when I had only the Java 8 runtime environment installed I could not launch the runnable JAR. With the Java 8 JDK I was able to run the runnable JAR as expected, with no problem.
i have made one desktop application with swing and i have uses one textfile (File) in it. i want to handover to another friend to use it . How to create jar file of that program with that text file so that my friend use it without any issue . I have made it in NetBeans
I've been working quite a bit with a login system the past couple of months and I now have a version that I would like to try "for real" by extracting it as a runnable .jar or .exe file. I've looked at a couple of guides that told me how to do this properly, but even after following every step precisely it didn't work.
One of the guides I tried: 3 Ways to Create an Executable File from Eclipse - wikiHow
Double clicking the file or selecting it and pressing enter does nothing, the computer loads for a second and then nothing happens. I don't receive any visible errors when extracting the program, either.
However, when running the file from the command prompt I do receive an odd error: Microsoft Windows [Version 6.2.9200] (c) 2012 Microsoft Corporation. All rights reserved.
C:UsersUserName>java -jar Login.jar Exception in thread "main" java.lang.IllegalArgumentException: input == null! at javax.imageio.ImageIO.read(Unknown Source) at LoginSystem.Data.updateData(Data.java:347) at LoginSystem.Data.<init>(Data.java:309) at LoginSystem.MainFrame.<init>(MainFrame.java:42) at LoginSystem.MainFrame.main(MainFrame.java:457)
C:UsersUserName>
I must say I don't quite understand the error, it seems to be unable to load an image which is odd considering the program works fine without any errors at all in Eclipse.
When I try to run my runnable jar file, it wont do anything. And when I try to run it from the console, it says
"java.lang.UnsatisfiedLinkError: no LWJGL in java.library.path..."
How do I fix this?
I've specified the path by properties > Libraries > lwjgl.jar > Native Library Location > .... And I chose the right paths. But I still get that java.lang.UnsatisfiedLinkError.
It says I'm getting an error on line 34 which is:
appgc = new AppGameContainer(new Game(gamename));
My whole main class is:
package net.battleboy; import org.newdawn.slick.*; import org.newdawn.slick.state.*; public class Game extends StateBasedGame { public static final String gamename = "Battle Boy 1.0 ALPHA"; public static final int menu = 0; public static final int play = 1; public static final int settings = 2;
how to create a JAR File I have been watching you tube and it seems like the manifest needs to be remade. I go to the CMD and find my project folder class. I think I need to use do the same for all the classes correct. Well I type jar -cf TictacToeGUIGame.jar *java then I get no such directory. I can see the it worked thought. So do i do this to all my classes and then I will have my JAR program?
Codebase: myserver.com Permissions: sandbox Application-Name: Dynamic Tree Demo
error message from command line:
C:UsersxxxxDesktopCOMP268applet_ComponentArch_DynamicTreeDemoapplet_Comp onentArch_DynamicTreeDemouildclasses>jar -cvfm DynamicTreeDemo.jar mymanifest .txt appletComponentArch java.io.IOException: invalid header field name: ?≫?Codebase at java.util.jar.Attributes.read(Attributes.java:433) at java.util.jar.Manifest.read(Manifest.java:199) at java.util.jar.Manifest.<init>(Manifest.java:69) at sun.tools.jar.Main.run(Main.java:172) at sun.tools.jar.Main.main(Main.java:1177) [/code] encoding in UTF-8 and have newline at end