Help with jar

hi,
so question-
how can i run a jar file?
thanks

OH just slap a
"main-class: package address.classnameofmainprogram"
in the manifest file of the jar.
Example:
manifest contents will have also
"main-class: pjb.myprgram.dumbprogram"
The jar was has the structure inside of /pjb/myprogram/ with dumbprgram in it
The following code is in the directories of
/javaprograms/pjb/myprogram/
/javaprograms/pjb/myprogram/dumbprogram.class
/javaprograms/pjb/myprogram/dumbprogram.java
package pjb.myprogram;
class dumbprogram {
}Then you can just db click on the jar. DBL click click click. If the gun dont fire.....
I know it works for MSwindows. Never tried it on a Mac, and aint tried it on a linux yet. But its nice a feature.
Or you can download one of them EXE builders.
http://directory.google.com/Top/Computers/Programming/Languages/Java/Development_Tools/Deployment/?tc=1
Welll
Have fun

Similar Messages

  • Please Help With Jar File

    I have a jar file named Helper.jar with
    com.xyz.util.Helper.class in it.
    Now I have a SrcFile.java that
    imports com.xyz.util.Helper;
    It compiles fine with:
    java -classpath Helper.jar;. SrcFile.java
    ...and runs fine with:
    java -cp Helper.jar;. SrcFile
    When I jar it with:
    jar cvfm SrcFile.jar SrcFile.mf *.class
    ...and run it with:
    java -cp Helper.jar;. -jar SrcFile.jar
    I get the following exception:
    java.lang.NoClassDefFoundError: com/xyz/util/Helper
    ...but yet, Helpler.jar runs fine with:
    java -jar Helper.jar
    Does anyone have any idea what I am doing wrong or
    do I have to un-jar the Helper.jar file and
    re-jar SrcFile.jar with all the .class files?

    I've replied to this same thread in the New To Java Technology fourm, see there for a suggestion.

  • Urgent help with jar file

    I'm writing a program in VB that calls on a JAR file. It has been working great for weeks. Last night, I moved the JAR file to a new location on my machine, and it suddenly stopped working at all.
    I know nothing about Java. Do I need to recompile the file? I tried moving the whole directory back to its original location but it didn't help.
    Thanks in advance.

    Dude I'm telling you straight up, the program has a bug. The evidence is in the error message. Maybe the bug was not manifested before, but it was there.
    Do you have access to the source? Do you know how to compile it? You should recompile it with the -g flag to include debug information. Then the error message will include a method name and line number for the offending portion of code. If you're not able to figure it out yourself, you could post that portion of code here for someone to comment on.

  • Now what? Help with .jar files

    Hey. I just finished a program. I want to share it with my friends or anyone else. I can create a .jar file but I have no idea what to do next. Is there an easy way to "publish" your programs (like create a .exe file?). Any help or ideas would be appreciated. Thanks, Merlot14

    java -jar MyFile.jarwill work if you've set your manifest correctly. If you're distributing only to Windows users, you could include a shortcut, I believe. Similarly, for distribution to Linux/OS X users, you could include a shell script.

  • Need help with jar files

    I have made an application that uses the javax.comm library for serial port drivers. It works perfectely but when I put all the .class in a .jar and start the application it starts properly with no errors but it doesn't see the com's of the computer.
    I would apreciate if you could help me out
    greetings
    paul

    You have to modify the source code of the javax.comm class files you are using.. the line contains "package javax.comm;" should be deleted. And then compile those modified files and put the compiled files to your jar file. Or you can create a folder "javax" and subfolder "comm" in that folder and put those original .class files into "javax/comm". After that, put that "javax" folder into your jar file.

  • Need a little help with JAR creation

    I've created a JAVA program with the Forte IDE and now I want to make it executable without the IDE. I read on this forum that all I had to do was create a JAR file, so I tried but I get an error (see below). Could someone point out my error please.
    Directory Tree:
    vio082\vio\app\
    DOS command to create executable JAR:
    "java -jar cmf trackerManifest.txt trackerTest.jar trackerTest.Class"
    ERROR I RECEIVED:
    "Exception in thread "main" java.util.zip.ZipException: The system cannot find the file specified
         at java.util.zip.ZipFile.open<Native Method>
         at java.util.zip.ZipFile.<init><Unknown Source>
         at java.util.zip.ZipFile.<init><Unknown Source>
         at java.util.zip.ZipFile.<init><Unknown Source>"
    This was my file trackerManifest.txt:
    Main Class: trackerTest
    [cr]
    This is the begining of my file trackerTest.Class:
    package vio.app;
    import javax.comm.*;
    import vio.tracker.*;
    import java.net.*;
    import java.io.*;
    public class trackerTest {
         public static void main (String argv[]) {

    Thanks for the help so far. My first problem was that the directory with the "jar" command was not in my path (now that fixed). My application still won't execute and I think it has to do with the following:
    My application uses the serial port to communicate with a device and uses a socket server to communicate with a C++ program. The following JAVA utilities are imported to make my application work:
    javax.comm.
    java.net.
    ijava.io.
    If I use the command:
    "jar cvfm trackerTest.jar trackerManifest.txt trackerTest.Class"
    will the appropriate files from javax.comm, java.net and ijava.io also be incorporated into the jar file? If not, how are they made available when I distribute my jar to other users?
    Second question:
    Should I be using:
    "jar cvfm trackerTest.jar trackerManifest.txt vio082/*.*"
    to capture all the other classes required by my package that are in other directories above and below the trackerTest.class directory?
    Any help is greatly appreciated.
    JAM

  • Need help with jar in jar

    Hi folks, I've got a serious(for me!) problem. I have a programm which contains several other jar files in a directory. If I run the program with Eclipse it works quiet well but if I create a Jar file from the whole program I always get the error message: No class def found error. It's the classes used from the included jar files that could not be found. So what should I do? In the jar file are all used class and jar files. Everything is there in the right order. But it doesn't work.
    I hope you can help me with that. One idea was that these other jar files have to be added to the manifest.mf ?! I've got no idea.

    For me it workes like this:
    manifest.mf:
    Manifest-Version: 1.0
    Main-Class: gui.testgui
    Class-Path: lib/castor.jar lib/xercesImpl.jar lib/xml-apis.jar
    I make my jar:
    jar cvfm myjar.jar manifest.mf .
    The dot stands for the directory where I am. All files and directories of this directory are jared.
    The information in my manifest-file are used to generate a manifest for the jar.

  • Help with Jar file exception

    I have been following the example of instruction at:
    http://forum.java.sun.com/thread.jsp?forum=31&thread=332680
    But I get an exception when I do the following.
    D:\pro>jar umf mf.txt myjar.class
    java.io.IOException: invalid header field
            at java.util.jar.Attributes.read(Attributes.java:359)
            at java.util.jar.Manifest.read(Manifest.java:162)
            at java.util.jar.Manifest.<init>(Manifest.java:52)
            at sun.tools.jar.Main.update(Main.java:487)
            at sun.tools.jar.Main.run(Main.java:167)
            at sun.tools.jar.Main.main(Main.java:904)Can somebody help me on this?
    Thanks I will really appreciate.

    I cannot execute the file, after I created, and then I add the mf intothe class, I double clicked but doesn't do anything.
    Should I run it with the java -jar myjar.jar?
    When I do it it throws me the following:
    D:\z>jar cf myjar.jar myjar.class
    D:\z>jar umf mf.txt myjar.class
    D:\z>java -jar myjar.jar
    Failed to load Main-Class manifest attribute from
    myjar.jar
    D:\chris\1\z>help please.

  • Help with JAR Files

    OK, folks, I need some help here...
    And I have researched on this prior to this post, but I still don't get it.
    I have a simple application in Reminder.java file. When I compile it, I get Reminder.class and Reminder$ReminderThread.class, because I have an inner class.
    I place those files in Reminder directory. I want to make an executable JAR file, so I made a manifest file outside the Reminder directory that contains these lines
    Manifest-Version: 1.0
    Main-Class: Reminder.Remindersince the Reminder.class is within the Reminder directory, I understood I had to have a prefix "Reminder."
    In the command line, I type
    jar cmf manifest Reminder.jar Reminder/Reminder.class Reminder/Reminder$ReminderThread.classAnd I do get a Reminder.jar file, but when I double-click on it, I get a popup saying "Could not find the main class. Program will exit!"
    So, what am I doing wrong and how can I fix this? As I said, I have researched, but I can't understand what went wrong nor how to fix the problem.
    Any help will be greatly appreciated.

    Never mind, I solved it, I was missing a carriage return in my manifest file. I feel so stupid now...

  • Help with JAR creation please

    I've created a JAVA program with the Forte IDE and now I want to make it executable without the IDE. I read on this forum that all I had to do was create a JAR file, so I tried but I get an error (see below). Could someone point out my error please.
    Also, I tried to run the jar command by itself, I received a command not found error. Only when I preceeded the jar command by JAVA (i.e. JAVA -jar ....) did DOS attempt to run the command.
    Second request: Am I missing the path to the jar command in my path variable?
    Directory Tree:
    vio082\vio\app\
    DOS command to create executable JAR:
    "java -jar cmf trackerManifest.txt trackerTest.jar trackerTest.Class"
    ERROR I RECEIVED:
    "Exception in thread "main" java.util.zip.ZipException: The system cannot find the file specified
    at java.util.zip.ZipFile.open<Native Method>
    at java.util.zip.ZipFile.<init><Unknown Source>
    at java.util.zip.ZipFile.<init><Unknown Source>
    at java.util.zip.ZipFile.<init><Unknown Source>"
    This was my file trackerManifest.txt:
    Main Class: trackerTest
    [cr]
    This is the begining of my file trackerTest.Class:
    package vio.app;
    import javax.comm.*;
    import vio.tracker.*;
    import java.net.*;
    import java.io.*;
    public class trackerTest {
    public static void main (String argv[]) {

    Hi there,
    I'd like to get in on this as well ... I've got a problem of my own with this. In the past I've created packages and ran them alright. And I create my own .jar files all the time on MS Win OS's, which I distribute for others and create desktop shortcuts for, etc. ... no problems; I sometimes jar up applications in unix, even though pretty much everything I run there is command line, just to keep things together.
    But I've never jar'd up an application with my OWN packages inside, rather than just the default directory path (IOW: with package statements) and now that I'm trying it's not working quite right ... here's the deal:
    Here's the path to the 1st package level: C:\MyMoveSubDir\Mysendrecv\Billsdir\TestPgms
    Here's the next dir level:
    mytestdir
    So, in C:\MyMoveSubDir\Mysendrecv\Billsdir\TestPgms\mytestdir is:
    TestClassy.class
    and
    TestClassy$P1.class
    ... created from:
    TestClassy.java ... the source is:
    package mytestdir;
    public class TestClassy {
    public static final void doNothing() {
    System.out.println("What a doNothing method");
    protected class P1 {
    void afancymethod() {
    System.out.println("What a fancy method");
    public static void main(String[] argv) {
    TestClassy tc = new TestClassy();
    tc.doNothing();
    P1 p1 = tc.new P1();
    p1.afancymethod();
    ... The manifest file is called mymanifest.txt, and is in:
    C:\MyMoveSubDir\Mysendrecv\Billsdir\TestPgms, and looks like this:
    Main-Class: mytestdir.TestClassy
    I compile the pgm from C:\MyMoveSubDir\Mysendrecv\Billsdir\TestPgms like this:
    javac -classpath . mytestdir\TestClassy.java
    I run the pgm from same like this:
    java -classpath . mytestdir/TestClassy
    ... and it prints:
    What a doNothing method
    What a fancy method
    ...fine.
    I can jar it up like this:
    C:\MYMOVE~1\MYSEND~1\Billsdir\TestPgms>jar cvfm TestClassyJar.jar mymanifest.txt -C mytestdir/ .
    added manifest
    adding: mytestdir/./(in = 0) (out= 0)(stored 0%)
    adding: mytestdir/./TestClassy$P1.class(in = 594) (out= 374)(deflated 37%)
    adding: mytestdir/./TestClassy.class(in = 681) (out= 436)(deflated 35%)
    adding: mytestdir/./TestClassy.java(in = 423) (out= 214)(deflated 49%)
    But no matter how I try to execute it - like this - it fails with:
    C:\MYMOVE~1\MYSEND~1\Billsdir\TestPgms>java -jar TestClassyJar.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: mytestdir/TestClassy
    ... any suggestions anyone. I'd sure appreciate it.
    ~Bill

  • Help with jars webstart and InputStream

    I am currently attempting to fix all the things that break
    the minute you attempt to use a jar under webstart.
    I have attempted to find an answer by searching the forums.
    I cannot determine how to overcome the following.
    I have third party jars for "Jasper reports" and the loadReport
    function requires a java.io.InputStream as input.
    "public static JasperReport loadReport(java.io.InputStream inputStream) throws JRException"
    The report templates are in my jar file in a sub directory "\sreports".
    I was loading the template with the following code.
    JasperReport template = JasperManager.loadReport(new FileInputStream(reportFile));
    Where
    String reportFile = ".\\sreports\\Std"+tableName+".jasper";
    I have tried several things including below.
    FileInputStream fs = new FileInputStream(getClass().getResource("sreports/StdEquipmentType.jasper"));
    which does not even complile.
    Rykk

    Get your input stream like:
    InputStream in = getClass().getResourceAsStream("path/to/file.txt");
    note that you use "/" and not "\" or "\\" no matter what OS you are using.

  • Newbie help with JAR files

    Okay,
    I built a simple Hello World project with Swing and it worked. Now I've build my own program from scratch and get a "Cannot find the main class" error from the JRE. Below are the contents of the manafest file craeted by Sun Java Studio 8.
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.6.2
    Created-By: 1.5.0_06-b05 (Sun Microsystems Inc.)
    Main-Class: localPkg.mainForm
    X-COMMENT: Main-Class will be added automatically by build
    Also here is the source code for localPkg.mainForm
    * mainForm.java
    * Created on January 17, 2006, 9:32 AM
    * @author rowen
    package localPkg;
    import java.beans.*;
    public class mainForm extends javax.swing.JFrame {
    /** Creates new form mainForm */
    public mainForm() {
    initComponents();
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
    private void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;
    ctoF1 = new MyBeans.CtoF();
    jLabel1 = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    numericField1 = new magicbeans.NumericField();
    numericField2 = new magicbeans.NumericField();
    ctoF1.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
    public void propertyChange(java.beans.PropertyChangeEvent evt) {
    ctoF1PropertyChange(evt);
    ctoF1PropertyChange1(evt);
    getContentPane().setLayout(new java.awt.GridBagLayout());
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    jLabel1.setText("Farenheight");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.ipadx = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.insets = new java.awt.Insets(20, 110, 0, 0);
    getContentPane().add(jLabel1, gridBagConstraints);
    jLabel2.setText("Celsius");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.insets = new java.awt.Insets(11, 110, 0, 0);
    getContentPane().add(jLabel2, gridBagConstraints);
    numericField1.setText("farenheightField");
    numericField1.setName("farenheightField");
    numericField1.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
    public void propertyChange(java.beans.PropertyChangeEvent evt) {
    numericField1PropertyChange(evt);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.gridwidth = 4;
    gridBagConstraints.ipadx = 119;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.insets = new java.awt.Insets(6, 110, 0, 160);
    getContentPane().add(numericField1, gridBagConstraints);
    numericField2.setText("celsiusField");
    numericField2.setName("celsiusField");
    numericField2.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
    public void propertyChange(java.beans.PropertyChangeEvent evt) {
    numericField2PropertyChange(evt);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.gridwidth = 3;
    gridBagConstraints.ipadx = 99;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.insets = new java.awt.Insets(6, 110, 191, 0);
    getContentPane().add(numericField2, gridBagConstraints);
    pack();
    // </editor-fold>
    private void numericField2PropertyChange(java.beans.PropertyChangeEvent evt) {                                            
    ctoF1.setC(numericField2.getValue());
    private void numericField1PropertyChange(java.beans.PropertyChangeEvent evt) {                                            
    ctoF1.setF(numericField1.getValue());
    private void ctoF1PropertyChange1(java.beans.PropertyChangeEvent evt) {                                     
    numericField2.setValue(ctoF1.getC());
    private void ctoF1PropertyChange(java.beans.PropertyChangeEvent evt) {                                    
    numericField1.setValue(ctoF1.getF());
    * @param args the command line arguments
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new mainForm().setVisible(true);
    // Variables declaration - do not modify
    private MyBeans.CtoF ctoF1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private magicbeans.NumericField numericField1;
    private magicbeans.NumericField numericField2;
    // End of variables declaration
    Using Sun Java Studio Enterprise 8 (patch 1), on Windows XP (most recent patches)
    Thanks in advance,
    Roy

    R_Owen ,
    One possible way of how to do it in JSE8 is:
    1. Put all necessary lib jars to some place under src folder.
    2. Add those jars into Compile-time libraries list (Project properties -> Libraries) for correct compilation
    3. Switch to 'Files' JSE8 tab, open manifest.mf file (it's in projects root) and add your lib jars to it.
    Syntax is:
    Class-Path: relative URLs
    That's it.
    And Class-Path attribute description from JAR File Specification:
    http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html#Main%20Attributes:
    �Class-Path:
    The value of this attribute specifies the relative URLs of the extensions or
    libraries that this application or extension needs.
    URLs are separated by one or more spaces.
    The application or extension class loader uses the value
    of this attribute to construct its internal search path. �
    Copy/paste from:
    http://swforum.sun.com/jive/thread.jspa?forumID=122&threadID=60169

  • Help with jar files and running them

    I have been trying to figure out how to run executable java files, now I have heard that a million and one people have asked this already. Though when I see the answer to these questions I am still quite confused, I would like to understand some things. First thing is how do you even save your java code as a jar file. Secondly, what is a jar file. Thirdly, I have seen many people talking about batch files, what are they? And finally, I have used many "wrappers" and I still cannot get it to work. Plz help

    A quick google search gave me [url http://neptune.netcomp.monash.edu.au/JavaHelp/howto/jar.htm]this website about jars.

  • Need help with Jar

    Ok,
    I created a .txt file with "Main-Class: MainClass" and save it as main.txt
    I put everything in the same folder,
    the main.txt and MainClass.class
    Then in command prompt I type..
    cmf main.txt MainClass.jar MainClass.class
    everything was fine, no error messages
    then i try to run the .jar file but I got an error that says..
    "Failed to load Main-Class manifest attribute from ....."
    Whats the problem???

    Oops...
    in the post
    cmf main.txt MainClass.jar MainClass.classI meant jar cmf main.txt MainClass.jar MainClass.class

  • Help with jar please.

    Hello!
    I created a jar file and I included all my folders in that file. unfortunately, when I'm running the file it doesn't show the images inside the folders i included.
    I'll be happy to know what the problem is.
    thanks a lot, Meir

    My problem is not just images but audio and icons...
    do I have to load all of this with different methods?
    there is no way to compress everything together and run it as jar file?
    Meir.

Maybe you are looking for

  • Tiger hates SCSI?

    I'm running a Minolta Dimage Scan Multi II, a film scanner, which is SCSI, and I run it off an Adaptec SCSI card in my Quicksilver G4. The scanner always worked fine until I upgraded the OS from 10.3.9 to 10.4.9. After the upgrade, the scanner wouldn

  • Creating a cache control

    Has anyone created a cache control for Workshop? I'm wanting to cach the results of a complex report by using the xbean. Then if the request parameters match an already generated report, I simply send back out a pregenerated xbean. The cache would ne

  • Is it good idea to use style sheet for the bgcolor of a table that is just

    is it good idea to use style sheet for the bgcolor of a table that is just being used for formatting

  • Sum of time formate

    id time 1 1.20 2 2.30 3 4.20 4 5.30 5 1.00 result expected = 14:40 or (if AM/PM so result=???) how can i calculate the sum of time ??? please give me some fast tricks of handling date/time formate in oracle....

  • Invoke CGI script in JSP?

    Hello All: I tried to use: <jsp:include flush="true" page="/cgi/test.cgi">to invoke CGI script. The problem is the parameters in request were not passed to CGI. There is no this issue if page invoked is JSP. I am using SunONE Web Server 6.1 I appreci