Executable jar help
I was told to make jar files executable like this
jar cf0 blah.jar *.class
create a txt say mainclass.txt
Main-class:Blah
then jar umf mainclass.txt blah.jar
i did that then ran with javaw
but told me main class not found
what is the precise steps to take
thanks
Get a decent zip editor that lets look inside the Jar file. Then make a directory called 'META-INF'. In it make a file call 'MANIFEST.MF'. Then put the words 'Main-class: Blah' into it. (Don't forget the space).
Similar Messages
-
Executable Jar file, please help!!!
I know this has been posted many times before, but Im going insane, and nothing is working, I will now have spent more time trying to make an executable jar file, than the time I spent actually writing the program, here's my problem
I got two classes, tictactoe.class, and whichBox.class, I want to make a jar file, I have tried many types of manifest files, none worked, my Main() is in tictactoe.class, if ANYONE can help me get this working I will give them dukes!!!!!I know this has been posted many times before, but Im
going insane, and nothing is working, I will now have
spent more time trying to make an executable jar file,
than the time I spent actually writing the program,
here's my problem
I got two classes, tictactoe.class, and
whichBox.class, I want to make a jar file, I have
tried many types of manifest files, none worked, my
Main() is in tictactoe.class, if ANYONE can help me
get this working I will give them dukes!!!!!
your manifest file should look like this...
Manifest-Version: 1.0
Main-Class: tictactoeplease note there must be a line return at the end of tictactoe. so the file should have three lines.
if you have this correct the only other thing i can suggest is are you sure it is your manifest file that is being added to the jar.
your jar command should look like the following assuming the jar files is called Game, your manifest is called game.mf and both files reside in the default package.
jar -cvfm Game.jar game.mf *.class hope this helps. -
Hi all,
I Trying to deploy a simple J2SE app by making an Executable JAR File, however I don'r understand how to add a valid value to the Main Class field.
I followed the following description within Jdev, after creating a Deployment Profile:
Deploying an Executable JAR File
You can make your simple archive or J2EE Client Module into an executable JAR file that you can launch with the java command.
To deploy an executable JAR file:
1) Select and right-click the simple archive or client icon in the Navigator to display the context menu.
2) Choose Properties.
3) Click JAR Options in the tree.
4) Select Include Manifest File (META-INF/MANIFEST.MF).
5) In the Main Class field, enter the fully qualified name of the application class that is to be invoked.
7) Click OK.
8) Launch the executable JAR file from the command line:
java -jar myapp.jar
where myapp represents your JAR file name.
Like I said it's in 5) I'm doing something worng
My deploy-file (PlotPrint.deploy) looks the following:
<?xml version = '1.0' encoding = 'windows-1252'?>
<client-deployment xmlns="http://xmlns.oracle.com/jdeveloper/903/deploy/j2ee-client-jar" nselem="client-deployment" class="oracle.jdeveloper.deploy.jar.ClientProfile">
<archiveOptions>
<additionalManifests/>
<compressed>false</compressed>
<hasManifest>true</hasManifest>
<mainClass>PlotPrintClient</mainClass>
</archiveOptions>
<archiveTargetPlatform/>
<cdaSettings>
<additionalArchives/>
<afterFilters/>
<beforeFilters/>
<duringFilters/>
<selectedArchives>
<archives>
<Item protocol="jar" path="file:/C:/Oracle9i_Jdev/jdevbin/jdbc/lib/classes12.jar!/"/>
<Item protocol="jar" path="file:/C:/Oracle9i_Jdev/jdevbin/jdbc/lib/nls_charset12.jar!/"/>
<Item protocol="jar" path="file:/C:/Oracle9i_Jdev/jdevbin/jdev/lib/jdev-rt.jar!/"/>
<Item protocol="jar" path="file:/C:/Oracle9i_Jdev/jdevbin/soap/lib/soap.jar!/"/>
<Item protocol="jar" path="file:/C:/Oracle9i_Jdev/jdevbin/lib/xmlparserv2.jar!/"/>
<Item protocol="jar" path="file:/C:/Oracle9i_Jdev/jdevbin/jlib/javax-ssl-1_2.jar!/"/>
<Item protocol="jar" path="file:/C:/Oracle9i_Jdev/jdevbin/jlib/jssl-1_2.jar!/"/>
<Item protocol="jar" path="file:/C:/Oracle9i_Jdev/jdevbin/j2ee/home/lib/activation.jar!/"/>
<Item protocol="jar" path="file:/C:/Oracle9i_Jdev/jdevbin/j2ee/home/lib/mail.jar!/"/>
<Item protocol="jar" path="file:/C:/Oracle9i_Jdev/jdevbin/j2ee/home/lib/http_client.jar!/"/>
<Item protocol="jar" path="file:/C:/Oracle9i_Jdev/jdevbin/webservices/lib/wsdl.jar!/"/>
<Item protocol="jar" path="file:/C:/Oracle9i_Jdev/jdevbin/lib/xmlparserv2.jar!/"/>
<Item protocol="jar" path="file:/C:/Oracle9i_Jdev/jdevbin/lib/xmlcomp.jar!/"/>
</archives>
<selectionMode>0</selectionMode>
</selectedArchives>
</cdaSettings>
<defaultConnection class="java.lang.String"/>
<deployClientMaxHeapSize/>
<earURL path="deploy/PlotPrint.ear"/>
<enterpriseAppName/>
<jarURL path="deploy/PlotPrint.jar"/>
<profileDeps/>
<properties/>
<selectedProjectFiles>
<autoInclude>true</autoInclude>
<deploySourceAs>0</deploySourceAs>
<files class="[Ljava.net.URL;"/>
<selectionFilters/>
</selectedProjectFiles>
</client-deployment>
I using Oracle9i Jdev, but have also tried it un the new Jdev 10g version, but the same problem everytime:
Error message: Could not find the main class: program will exit.
Please help I really need this to work
Message was edited by:
MHCI
Message was edited by:
MHCIYes that was the problem so I have changed the element mainClass to
<mainClass>xxPlotPrint.MHCI.PlotPrintClient</mainClass>
But now another probem has occured, since I get the following error when run the jar-file (When I run the app from within Jdev there are no warnings or errors).
----Batch-file-----
@echo off
java -jar PlotPrint.jar
echo Test Plot and Print Batch-file!
pause
---- out to cmd ----
Exception in thread "Thread-0" java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl
at xxPlotPrint.MHCI.NNE35_worker.run(NNE35_worker.java:42)
at java.lang.Thread.run(Unknown Source)
Exception in thread "Thread-2" java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl
at xxPlotPrint.MHCI.OCEJobDB_worker.run(OCEJobDB_worker.java:41)
at java.lang.Thread.run(Unknown Source)
Exception in thread "Thread-1" java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl
at xxPlotPrint.MHCI.NNE27_worker.run(NNE27_worker.java:42)
at java.lang.Thread.run(Unknown Source)
It's the same problem in all three exceptions (the exactly the same code), however I was a bit to quick this is the line (the line before I process the xml doc :-)
import org.w3c.dom.Element;
responseData = new Vector();
responseData = test_NNE35_SOAP.getXSDdoc();
Element elements = ( (org.w3c.dom.Element)responseData.elementAt(0) ); (line 42)
Please help I don't understad why I receive this exception, since I included the xmlparserv2.jar file, and don't even have a workaround :-( -
Need help with loading images in executable Jar
Hi,
I've developed an application using netbeans that needs to load and display images.
I use netbeans Clean and Build function to create an executable Jar file. When I run the executable Jar file it runs fine but when I come to a section of the application that needs images it freezes and can't load the images.
When I then return to netbeans the part of the program that did successfully run before Clean and Build doesn't work anymore and I get an error message saying Uncaught error fetching image:
I use,
URL url = getClass().getResource("images/image1.png");
Image image1 = Toolkit.getDefaultToolkit().getImage(url);to load an image.
Can someone tell me why, when I clean and build my project to create a JAR, my images fail to load.
Should I be storing the images in a specific folder or something??
ThanksI've opened the JAR using winzip and, for some reason, the JAR hasn't preserved my file structure. So, when I try to look for an image as follows:
URL url = getClass().getResource("images/file1.png");
Image img= Toolkit.getDefaultToolkit().getImage(url);The folder doesn't exist and so it can't find the image.
Can someone tell me how to keep my file structure when I create the JAR or an alternative way to find the images within the JAR file.
Cheers -
Links not working in executable jar
I have a problem with my java application
html and images files do not work in executable jar
though the application works normally
I tried some suggestion but I received an exception thread indicating problem at
ImageIcon iChing = new ImageIcon(imageURL);
Please could you help me thank you so much
here is the class
public class Main extends JFrame
* objects required for the GUI: JFrame,JLabel, JButton, ImageIcon, JPanel,
* Dimension
private static final long serialVersionUID = 1L;
JButton jbEnter;
ImageIcon iChing, logo;
JPanel buttonPanel, ImagePanel;
JLabel jlbIching;
Dimension dim;
URL imageURL;
File fileName;
// Class constructor to create the GUI
public Main()
Container container = getContentPane();
URL imageURL = this.getClass().getClassLoader().getResource("src/myFiles/iching.gif");
ImageIcon iChing = new ImageIcon(imageURL);
jlbIching = new JLabel(iChing);
// button to go to the Title class
jbEnter = new JButton("Enter ");
jbEnter.setBorderPainted(false);
jbEnter.setFont(new Font("Edwardian Script ITC", Font.BOLD, 42));
jbEnter.setBackground(new Color(0, 0, 50));
jbEnter.setForeground(Color.YELLOW);
jbEnter.addActionListener(new ActionListener() {
// method to render the current frame invisible and trigger the
// Welcome Menu
public void actionPerformed(ActionEvent e)
setVisible(false);
// this line does not work...............
new Title();
} // close the actionPerformed(ActionEvent e) Method
}); // close the addActionListener(new ActionListener() method
// Panel holding the decorative image and Button
ImagePanel = new JPanel();
ImagePanel.add(jlbIching);
ImagePanel.setBackground(new Color(0, 0, 50));
buttonPanel = new JPanel();
buttonPanel.add(jbEnter);
buttonPanel.setBackground(new Color(0, 0, 50));
// setting up of the panels position
container.add(ImagePanel, BorderLayout.CENTER);
container.add(buttonPanel, BorderLayout.SOUTH);
dim = Toolkit.getDefaultToolkit().getScreenSize();
dim.width = dim.width / 2 - 300;
dim.height = dim.height / 2 - 250;
setBounds(dim.width, dim.height, 400, 400);
setSize(600, 500);
setResizable(false);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//To set the icon for the application. Top left hand corner.
//this.setIconImage(Image);
setIconImage(new ImageIcon("src/myFiles/ichingRose.gif").getImage());
} // close the Constructor
* the main method for the program.
* @param args
* The command-line arguments.
public static void main(String[] args)
new Main();
} // close the main method
} // close the Main classThank you very much for your quick reply and really hope you can help me a little more
it's so frustrating
I do not really know about the relative path but here is my xml file
<?xml version="1.0" encoding="UTF-8" ?>
<project default="jar">
<!-- Compile and zip the source code into a jar -->
<target name="jar">
<!-- Make the folders we'll need -->
<mkdir dir="ant"/>
<mkdir dir="work"/>
<mkdir dir="ant/myFiles"/
<!--
Compile all the .java files into .class files
debug = yes Include debug information in the .class files
destdir Where to put the .class files
source and target Use Java version 1.6.0_06
-->
<javac
debug="yes"
destdir="ant"
source="1.6"
target="1.6">
<!-- Folders that have trees of .java files to compile -->
<src path="src"/>
</javac>
<copy todir="ant/myFiles"><fileset dir="src/myFiles"></fileset></copy>
<!--
Zip files together to make a jar
jarfile Where to make the .jar file, overwrite something there
basedir Find the files to zip in the jar here
-->
<jar
jarfile="work/BookOfChanges.jar"
basedir="ant"
>
<!-- Write a manifest inside the jar -->
<manifest>
<!-- The class Java will run when the user double-clicks the jar -->
<attribute name="Main-Class" value="iChing.Main"/>
</manifest>
</jar>
</target>
</project> -
Class not found error while executing jar file
I have written a java code in which i am connecting to database....when i run the class file using......java class_filename it works........
but when i run the jar file using .......java -jar jar_name ...yi gives me the error as 'Class not found'......
can anybody help me please......
Thanks and Regards,
Siddheshthat class is part of jar file.....in classpath i have included zip files for jdbc ...to get databse connection.....and the jar being executed ................still it gives the error ClassDefnotfound which i think is due to database connection problem.....the exception is raised while.....
Class.ForName("Driver_name").newInstance();/ This driver is present in zip files that i have added in classpath....
above statement doesn,t giv error while i execute the class file............but exception while executing jar file only..
Thnaks and regards,
siddhesh -
Executable JAR file: Could not find the main class.
Hello,
I have a problem with making an executable JAR file.
I have written a JAVA program that consists of five different classes of which User.java is the main class and I have saved a text document with Main-Class: User and a blank line after that.
If I try:
jar cmf MainClass.txt User.jar User.class Beheerder.class Operator.class Manager.class MaakVisueelSchema.class
it makes a executable jar file which actually works! :)
But when the Operator class trys to open the MaakVisueelSchema class the screen stays blank.
I can run MaakVisueelSchema with java MaakVisueelSchema.
So I tried to make an executable JAR that consists only of MaakVisueelSchema, the same way as I did for User:
Main-Class: MaakVisueelSchema
jar cmf MainClass.txt MaakVisueelSchema.jar MaakVisueelSchema.class
Then I get the error message:
Could not find the main class. Program will exit.
from the Java Virtual Machine Launcher.
The big difference between MaakVisueelSchema and the other classes is that MaakVisueelSchema contains a PaintComponent method and an ComponentListener. Is it possible that one of those creates the error?
Can anyone help me with this problem?
Thanks in advance!
Bye!Yes,
I tried:
jar xvf MaakVisueelSchema.jar
and it returns:
META-INF/
META-INF/MANIFEST.MF
MaakVisueelSchema.classN/G. You need to manually create a manifest file in a text editor, have it point to your main class, and enter it in your jar command as an argument. -
Problem running my program only after making an executable jar...
Hi everyone,
I am having trouble running my program after creating an executable jar. The program runs fine until
it is supposed to open a specific JFrame. I get the following error message as soon as the frame tries
to open:
Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: org.apache.xerces.parsers.SAXParser.<init>(Lorg/apache/xerces/xni/parser/XMLParserConfigurat
ion;
Has anyone ever seen this before?
The strange thing is, this does not happen when I build and run the project under Eclipse.
Any help or tips would be appreciated!
ChrisRoosh wrote:
The strange thing is, this does not happen when I build and run the project under Eclipse.
Any help or tips would be appreciated!Make sure you are using the same version of Java as you use with Eclipse. -
Could not find the main class error with executable jar
Hello,
I have troubles creating an executable jar file and I ran out of ideas how to solve it so I would appreciate some help.
I have created a jar file with the export function in eclipse
the Manifest.MF file contains:
Manifest-Version: 1.0
Main-Class: view.AppTennisViewI tried starting the file with a batch file which contains following code:
@echo off
javaw -classpath c:\TennisHSQLDB_GC2\tennisApp.jar
@start javaw -jar tennisApp.jar
exitthe batch file and the jar are both located in c:\TennisHSQLDB_GC2.
When i try command line I get the same result.
I also tried alternate statements such as SET CLASSPATH iso javaw -classpath and including the classpath in the manifest file but no luck. It keeps given me the error: could not find the main class. program will exit
Anyone any suggestions for my problem?nevermind, found it.
classpath in manifest was incorrect -
Classpath is not working for executable jar file
I have created executable jar file using following command where manifest file contains Main-Class and Class-Path entries.
jar cvfm app.jar META-INF/* lib/* *.class
So here app.jar contains my external jar's in lib directory
but when I move app.jar to another directory, it's doesn't get my external files.
I'm not getting this problem as these jar's are in app.jar
class-path entry in manifest file:
Class-Path: lib/abc.jar lib/xyz.jar
Pls help me where it is getting fail?
Thanks in advance,
VikasJava doesn't handle jars within jars. Your library jars need to be outside of the executable jar as in
dist - main.jar
- lib - lib1.jar
- lib2.jar -
Executable JAR witn anoter JAR
Hello, I need some help to be able to create an Executable JAR from a project containing already one JAR
Here is the situation :
I've made a program who acceses Oracle DB and therefore I have integrated an External JAR (ojdc14_g.jar) in my project so I can get access to the classes needed to synchronize with the DB.
I'm using Eclipse so I was able to generate automatically an auto-executable JAR. But the problem is that obviously the import statement :
import oracle.jdbc.*;
that I'm using to access the classes in the oracle External JAR is not undersood by the auto-executable JAR and I get :
A fatal exception occured - Program will Exit
Anyone an idea ??
PS: the generation of auto-executable JAR with eclipse works perfectly with my other projects
I'm using j2sdk 1.4.2.05
Thanks in advanceHi guys!
Sorry for the dot, I had missed that :(
But still doesn't work.....
I have been trying the following :
Class-Path: . ./JarLibrary/ojdbc14_g.jar
Class-Path: . /JarLibrary/ojdbc14_g.jar
Class-Path: . JarLibrary/ojdbc14_g.jar
Class-Path: . .\JarLibrary\ojdbc14_g.jar
Class-Path: . \JarLibrary\ojdbc14_g.jar
Class-Path: . JarLibrary\ojdbc14_g.jar
and even
Class-Path: . .JarLibrary.ojdbc14_g.jar
Class-Path: . JarLibrary.ojdbc14_g.jar
But I always get NoClassDefFoundError
any ideas ? Could it be my java version ? I'm working with 1.4.2_05
or any other ideas to be able to double-click on a Icon to run an Java application ?
Hope I can give you those 10 Dukes soon -
Create the executable jar's file
Hi guys,
I am working on java desktop's application where a user will be able to run the application by double click the executable jar file. I followed the description of "Creating and Deploying a Simple Archive to Your File System of the help. After creating the jar file and when I double click on jar file to run the application I got this error message "Could not find the main class. Program will exit". I was not also able to run the application on the dos command.
Please help. I don't have any problem when I run from Jdeveloper 9.0.4. I have window XP professional.
Your input will be very welcomed.OK open up your deployed Jar file in something like Winzip and have a look at the Manifest.MF in meta-inf\
I've just created an executable JAR with a main class of mypackage1.Class1 and it all ran ok. Here's the manifest:
Manifest-Version: 1.0
Main-Class: mypackage1.Class1
Created-By: Oracle9i JDeveloper 9.0.2So make sure your's is similar and your Main-class looks the same - e.g. does not say something like:
Main-Class: mypackage1.Class1.class -
Executable JAR using JDeveloper
Hi,
I created a very small Desktop Application using JDeveloper.
What I want to do is to create an executable JAR file. I mean, is there any option in this tool like the one in Eclipse. Once executable JAR is created, I must be able to run it just by double clicking the JAR file.
So, can some1 please help me with the steps ?
JDeveloper : 11.1.1.6.0For executable jar you will need to add:
Main-Class: your_package.YourClassto META-INF/MANIFEST.MF file inside jar.
I don't think that JDeveloper support custom manifest files so you can modify this content after jar creation(for example, with some zip/rar/7z tool)
Also, if your app require some additional jars, then you will need to add this line to manifest:
Class-Path: additional.jarDario -
Hi
i have a question for you.
I create a jar of my application in jbuilder 2007 and when i execute with
java -jar test.jar it's work fine.
After i try to create an executable jar but when i execute it i have a problem.
In a class i have error (java.lang.unsupportedclassversionerror..... major.minor version 49)
i think that jbuilder create my executable file using jre 1.4 and does'nt use my jvm version 5.
can you help me?Hi
i have a question for you.
I create a jar of my application in jbuilder 2007 and
when i execute with
java -jar test.jar it's work fine.
After i try to create an executable jar but when i
execute it i have a problem.
In a class i have error
(java.lang.unsupportedclassversionerror.....
major.minor version 49)
i think that jbuilder create my executable file using
jre 1.4 and does'nt use my jvm version 5.
can you help me?No, that means that you are trying to execute the application using a JRE that is too old. E.g. trying to execute with 1.4 but your classes requires 1.5.
See what java -version gives
Kaj -
SWT Runs in Eclipse - Not after export (NOT executable JAR)
I have been working on my first SWT application. It will run when using the Eclipse run command. However, when I export the project to a JAR file I can't get the module to run. I am NOT trying to run this as an executable JAR. I will eventually get to that, but for the moment I just want to be able to execute the module via the standard Java command.
When I try to run the module via:
java com.myproj.visual.SearchDisplay I get the following result:
NoClassDefFoundError: org/eclipse/swt/widgets/LayoutI have tried every variation of running this that I can find. I have the swt.jar as well as the jar containing my project files in the class path. I have extracted the DLL files from swt.jar and put them in the directory from which I am executing the module, i.e. I change directory to there before executing the Java command. I tried including the following in the Java command:
-Djava.library.path=c:\projects\java\myproj\swt-win32-3139.dllI have also tried including the classpath at the Java command:
-classpath .;c:\projects\java\myproj\swt.jar;c:\projects\java\myproj\mmstat.jarSo far nothing has helped. I get the same error regardless what I do. Yet this runs fine inside Eclipse.
In my Eclipse environment I do have swt.jar imported. And have org.eclipse.swt in my Require Projects tab on the Build Path. I also have swt.jar and Standard Widget Toolkit identified in the Libraries tab of the Build Path. And on the Order and Export tab I have tried including all three (Standard Widget Toolkit, swt.jar and org.eclipse.swt) and then each one separately and then in combinations.
It is obvious that I am not exporting correctly or I don't have the correct configuration at runtime. But I can not figure this out. I have been reading forums for days now. They mostly are concerned with excecutable JARs which is not yet my problem. I first need to get this working before worrying about packaging an executable.
Can someone please help suggest some solutions for me?
It would be GREATLY appreciated.
Glenn Puckett
Lexington, KYMaking a jar file from SWT project, in Eclipse:
1. Create one manifest file in project with following contents:
Manifest-Version: 1.0
Class-path: swt.jar
Main-class: package.MainClass
2. Export jar file with this manifest file
a) Right-click on project
b) Selection Export
c) Select Java and Jar file
d) Select the project, classpath and file project
e) In jar file textbox enter the name for jar file and select options: "Exports generated class files and resources" and "Compress the content of the jar file"
f) Press Next button
g) Press Next button
h) Select "Use existing manifest from workspace" and select the manifest file which you has created
i) Press Finish button
3. Put togheter the jar file and swt.jar
4. Run jar file
Maybe you are looking for
-
Extreamly Unhappy How I was treated by Verizon Customer service supervisor
My father recently passed away from lung CA back in August. I called Verizon in August about a week after he passed to find out if I can disconnect the service, at that time I asked the customer service rep if I can port the number to a google voice
-
Safari is blocked by fraudulent claim that my computer is infiltrated by suspicious activity
Unable to use Safari as it is blocked by a (fraudulent) message that my computer has an error due to suspicious activity. How can I unblock Safari?
-
Hi All, I have created some entries in 3KEI t-code. I guess it doesnt generate Transport request. Do we need to manually create a transport request for this also like Substitution/validation? Regards Suresh
-
Hi, I've made a little script for myself (well not only for myself) for switching between states of bluetooth and wifi. weird thing is, when I run it from the command line, it works just fine. when I call it via acpi it cycles only two stages back an
-
Sorting by Member's Alias name during dimension build
I dynamically build/update an Employee dimension each month. I want to sort the members by their alias name, which in this case is the employee name. Has anyone done this before? The data file which I'm using to build the outline is already sort by e