Help with creating jar file and running it ?

Hey guys,
I have a program with a package called classes and a sub-package called classes.mainLib.
I am trying to create a JAR file of the class files in mainLib. There is only one class file in classes and that contains the main method. So this is what i am doing:
1. create a manifest file with: Main-Class: classes.Cars
2. from within the mainLib directory (./program_name/classes/mainLib/) i do this:
jar cvf mainLib.jar manifest ./*.class
3. Then i move this jar file to ./program_name/lib and change directory to ./program name/
4. try to do this: java -jar ./lib/mainLib.jar
But it errors with:
gary@linuxbox:~/java/cars$ java -jar ./lib/mainLib.jar
Failed to load Main-Class manifest attribute from
./lib/mainLib.jar
Any ideas why this is happening. the manifest is included in the jar'ing
Thanks.

At a glance, it looks like you are placing only the
class files in the jar and trying to navigate your
classpath to run it. Instead, you have to place ALL
the package folders into the jar from the root of
your package hierarchy and the jar runs anywhere, in
any folder. The packages are INSIDE the jar.
also I see cars/classes in a path you describe ...and
the program seems to wnat classes/Cars ??? Could
this be an additional issue (or am I missing seeing
something about your package structure)?Firstly, i believe all my spelling and cases are correct.
I have the following strcuture:
Cars.class (contains main) : package classes in ./classes directory
All other classes : package classes.mainLib in ./classes/mainLib
I would like to jar ALL files in mainLib but not the class that contains the main method. Is this possible?
I'm not sure how clear i was earlier, hope this is more understandable.

Similar Messages

  • 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.

  • Oracle 9i: Help with loadjava jar files to call out web service from pl/sql

    I'm trying to build a web service client using dbws_callout_utility.zip (version used for prio 10g database). I followed the articles in oracle site to loadjava jar files (soap.jar, dms.jar, ejb.jar, jssl-1_1.jar, mail.jar, servlet.jar) into Oracle DB 9i before invoke jpub to gen stub class and wrappers in oracle 9i but i have many errors such as ora-29534 and ora-29521. As consequence i could not invoke jpublisher to generate code.
    Pls. help my with detail guide to overcome these errors, thanks in advance! My DB is Oracle 9.2.0.5

    Dear,
    I have read your article, it is useful for me. But I cannot Apply to my case. Please kindly help me. Thank you.
    When running, the error occurs:
    1:39:31 Execution failed: ORA-20000: soapenv:Server.userException - org.xml.sax.SAXParseException: Attribute name "password" associated with an element type "user" must be followed by the ' = ' character.
    My webservice Url: http://abc.com.vn:81/axis/ABC_WS_TEST.jws?wsdl
    I make PL/SQL (similiar as your example)
    FUNCTION INVOKESENDMT
    RETURN VARCHAR2
    AS
    l_request soap_api.t_request;
    l_response soap_api.t_response;
    l_return VARCHAR2(32767);
    l_url VARCHAR2(32767);
    l_namespace VARCHAR2(32767);
    l_method VARCHAR2(32767);
    l_soap_action VARCHAR2(32767);
    l_result_name VARCHAR2(32767);
    p_zipcode VARCHAR2(160);
    BEGIN
    --p_zipcode:='''TEST'' ; ''TEST'';''84912187098'';''84912187098'';''0'';''8118'';''1'';''000001'';''ThuNghiem'';''''';
    p_zipcode:='TEST';
    -- Set proxy details if no direct net connection.
    --UTL_HTTP.set_proxy('myproxy:4480', NULL);
    --UTL_HTTP.set_persistent_conn_support(TRUE);
    -- Set proxy authentication if necessary.
    --soap_api.set_proxy_authentication(p_username => 'TEST',
    -- p_password => 'TEST');
    l_url := 'http://abc.com.vn:81/axis/ABC_WS_TEST.jws';
    l_namespace := 'xmlns="' || l_url || '"';
    l_method := 'sendMT';
    l_soap_action := l_url || '#sendMT';
    l_result_name := 'sendMTResponse';
    l_request := soap_api.new_request(p_method => l_method,
    p_namespace => l_namespace);
    soap_api.add_parameter(p_request => l_request,
    p_name => 'user password sender receiver chargedflag servicenumber messagetype messageid textcontent binarycontent',
    p_type => 'xsd:string',
    p_value => p_zipcode);
    l_response := soap_api.invoke(p_request => l_request,
    p_url => l_url,
    p_action => l_soap_action);
    l_return := soap_api.get_return_value(p_response => l_response,
    p_name => l_result_name,
    p_namespace => l_namespace);
    RETURN l_return;
    END;

  • Need urgent help with creating .war file ...

    My boss gave me one day to create an app. that runs on Apache Tomcat 4.0.6. I managed to get it done, but now I'm trying to move it from my machine to the web server. Each time I try to create a .war file I get an error saying "no such file or directory". Am I missing a step here??
    What I do is: go to the webapps/<appname> directory where the app. is located, type in jar cvf * path/to/application/appname.war.
    I then get the "no such file..." message, then a message that says "added manifest" then lines on the screen that say adding: blah blah file. It goes through all the files in my app directory but I get no resulting .war file.
    I'm so frustrated and confused at this point, any help would be greatly appreciated.

    >
    What I do is: go to the webapps/<appname> directory
    where the app. is located, type in jar cvf *
    path/to/application/appname.war. No need to create an intermediate zip file, or to use JDeveloper to create a simple war file.
    You just need to put the WAR name before the list of files.
    jar cvf appName.war *

  • Help with Using JAR files

    I'm attempting to run a Java program that is contained in a .JAR file. The problem is not with that .JAR but with referencing a second .JAR for support classes. The problem is that I've created a support .JAR with two classes: Compute and Task called "Compute.jar". I've created a second class "ComputeEngine.jar" (in case you're wondering, this is the RMI example from the Sun website). I'm trying to compile this in XCode (Mac OS X IDE) which I'm not too familiar with but getting the hang of it.
    I've gotten far enough to reference the Compute.jar in the compiling and building of ComputeEngine.jar but when I run the ComputeEngine.jar, I get nothing. So I use a terminal window to run the ComputeEngine.jar with "java" command. Here's what happens:
    I enter: java -cp /Developers/Projects/Compute/build/Compute.jar -jar "ComputeEngine.jar"And I get an error: Exception in thread "main" java.lang.ClassDefNotFoundError: compute/ComputeI'm not sure why this is happening. Here is the jar tf Compute.jar output:
    META-INF/
    META-INF/MANIFEST.MF
    compute/
    compute/Compute.class
    compute/Task.classAnyone have a clue?
    Thanks
    Matt

    Thanks for the prompt response. Forgive my ignorace, but I'm new to JARs (actually wouldn't have been using it but for the fact that XCode defaults to that type of target). How do I specify the classpath in my jar? And which jar are we talking about? The Compute.jar or the ComputeEngine.jar?
    Thanks again.

  • Please Help with creating .jar's

    Ok, so I get how to make them, the commands, the manifests, etc.
    But for god's sake my DOS doesnt seem to have access to a jar.exe to run. I can type in:
    c:\some path> jar cmvf manifest.txt jarname.jar file1 file2
    It keeps telling me jar is not a recognized command... i read a part about needing jar.exe in the directory where you're working. Do I have to copy-paste jar.exe into any file I want to make a .jar in? Can I just add jar.exe to windows directory or something to make it a default DOS command?

    yeah, i was curious if i could add it to my system32
    folder and make it a default dos command, I guess
    not... now I have another issue, i have a manifest
    file with:
    Main-Class: Cyptography
    Name: JS/Cryptography
    Specification-Title: JCrypto
    Specification-Version: .2f
    Specification-Vendor: ME
    Implementation-Title: JCrypto
    Implementation-Version: build3
    Implementation-Vendor: ME
    Sealed: true
    and it loads into the jar fine (I unzipped it and
    checked the manifest.mf file in a text editor to make
    sure). But when i run java -jar CryptoStudy.jar, it
    says:
    Exception in thread "main"
    java.lang.NoClassDefFoundError: Cyrptography
    Now my Cryptography.class file is in the .jar along
    with everything else I need. sooo what gives?
    Manifest main-class is defined, class is included in
    n jar, manifest in the jar is correct... why will it
    not run my program? Do I need to package my class
    somehow? (if so how?)You misspelt "Cryptography"

  • Help with signing jar files

    hi,
    Iam trying to let a applet do file acces on a client. Therefore I must sign a applet so it may access the filesystem. This works, but the code keeps screaming about security violations.
    Now ive vopied the code from a example from Oracle and I found one difference.
    next to the fileUploader class that I also have in my jar file there is a
    FileUploader$1.class with the following code:
    import oracle.ewt.thread.Task;
    import oracle.ewt.thread.TaskEvent;
    final synchronized class FileUploader$1 implements Task
        private final FileUploader this$0 = fileUploader;
        private final boolean val$nf = flag;
        private final Object val$val = object;
        public void runTask(TaskEvent taskEvent)
            FileUploader.access$0(this$0, val$val, val$nf);
        FileUploader$1(boolean flag, FileUploader fileUploader, Object object)
    }but if I try to compile this code then I get all sorts of error telling me Iam missing vars and methods.
    Can anyone tell me why this class is there and what it does and if its nessesary for the fileaccess then how can I create it

    hi,
    Iam trying to let a applet do file acces on a client.
    Therefore I must sign a applet so it may access the
    filesystem. This works, but the code keeps screaming
    about security violations.
    Now ive vopied the code from a example from Oracle and
    I found one difference.
    next to the fileUploader class that I also have in my
    jar file there is a
    FileUploader$1.class with the following code:
    import oracle.ewt.thread.Task;
    import oracle.ewt.thread.TaskEvent;
    final synchronized class FileUploader$1 implements
    Task
    private final FileUploader this$0 = fileUploader;
    private final boolean val$nf = flag;
    private final Object val$val = object;
    public void runTask(TaskEvent taskEvent)
    FileUploader.access$0(this$0, val$val,
    al$val, val$nf);
    FileUploader$1(boolean flag, FileUploader
    der fileUploader, Object object)
    }but if I try to compile this code then I get all sorts
    of error telling me Iam missing vars and methods.
    Can anyone tell me why this class is there and what it
    does and if its nessesary for the fileaccess then how
    can I create it
    a Name1$Name2.class file is generated from an inner class Name2 in a class Name1.
    in your case you want to look at and compile FileUploader.java. This will then generate any inner class FileUploader$innerclass.class files necessary

  • Help please - Updating .jar file and can't compile decompiled .java files.

    Ok, so there is a game on the internet called 'runescape', its a java applet that runs in the web browser from a cache in the windows directory.
    Basically im trying to edit this client so that i can run it away from their website (for use on a private server).
    The problem i am getting is that when i decompile the class files from the .jar into the .java files i can't recompile the .java files.
    E.G. I decompiled one of the .class files and tried to re-compile it agian straight away which brought me errors, i did this to rule out my editing as the problem.
    The jar file can be found [here.|http://world80.runescape.com/loader_gl397188536.jar] but the link will no double be dead after a few weeks.
    Can somebody please take a look and help me? I'm fairly new to java programming so if you could keep your answers as simple as possible that would be great, thanks.
    Ps. If this is the wrong section im sorry, i couldn't find the right section and this section seemed closest for me.

    i'm compiling using the javac command in a batch file, its displaying 100 errors but there are more, it seems to be showing that the syntax is incorrect as it is labeling brackets as being in the incorrect places.
    Decompiling error?
    As for being allowed to do this, im not so sure the company would approve but im only doing this for learning purposes and will not be releasing any of it upon the internet.

  • Help with backing up files and opening from disk image.

    I am trying to back up my hard drive so that I can send my PowerBook in for repair. I used disk utility from my Panther install discs to create a disk image of my HD.
    The disk image was created successfully and mounts perfectly on my HD. I can open it and open all of my files from the disk image just fine when it is mounted on my PowerBook.
    However, when I take it to a different Mac, things start getting sketchy. I can open Word files just fine, but Excel files claim they are read-only and cannot open. I checked the permission back on my PowerBook to see what was up, and the files were read/write for the owner and read-only for groups and others, but they should still open as read-only files right? I even checked the permissions on the Word files to see if there was a difference, but there was no difference.
    I can take the external HD back to my PowerBook, remount it, and open everything fine, but then on the other Mac it is a no go.
    I need to back this up for when it is out on repair, but I need to know that the files will open in case I need to restore my disk.
    Can anyone help??
    BTW, I couldn't find the best forum to post this in, if there is a better one please direct me there...

    solution:
    I went into the Apple Store nearby today to send my PowerBook off for repair for a screen issue, and in the process got help with my backing up issue.
    It seems all one needs to do is copy the file from the external hard drive to the internal drive.
    It was that simple.
    Jason

  • Want help to create jar file

    Hi....
    To Run my project user should install some software�s.. so I want to create a JAR file
    Using that user can install my software�s.
    I have created a JAR file using � jar cvfm Test. jar manifest.mf gsv48w32.exe jdk-1_5_0_06-windows-i586-p.exe � it is working fine. Only when those two .exe file are in the directory where my jar file is executing
    But I want to give only Test.jar to users I don�t want to give gsv48w32,Jdk 1.5.
    Is there any way to create a jar file.
    Thanks
    Graj

    i am sending the code i used
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import java.awt.Container;
    public class DefaultSample {
    public static void main(String args[]) {
         JFrame frame = new JFrame("Default Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    ActionListener actionListener = new ActionListener() {
    public void actionPerformed(ActionEvent actionEvent) {
              if(actionEvent.getActionCommand()=="press this button if u want to install Gsview")
                   try{
                   Runtime.getRuntime().exec("gsv48w32.exe");
                        catch(Exception e)
              else
                   try{
                   Runtime.getRuntime().exec("jdk-1_5_0_06-windows-i586-p.exe");
                        catch(Exception e)
    JPanel panel = new JPanel();
    JButton defaultButton = new JButton("press this button if u want to install Gsview");
    defaultButton.addActionListener(actionListener);
    panel.add(defaultButton);
    JButton otherButton = new JButton("press this button if u want to install java 1.5");
    otherButton.addActionListener(actionListener);
    panel.add(otherButton);
         Container contentPane = frame.getContentPane();
    contentPane.add(panel);
    frame.getRootPane().setDefaultButton(defaultButton);
    frame.setSize(700,600);
    panel.setVisible(true);
    frame.setVisible(true);
    }

  • Help with runnin JAR files

    java -cp smpp.jar:smscsim.jar com.logica.smscsim.Simulator
    Can someone explain this line. Where do the jar files have to be located for this to work. also what is the function of the com.logica.smscsim.Simulator. Does it mean that the jar files should be in com.logica.smscsim. I try it and it gives me
    Exception in thread "main" java.lang.NoClassDefFoundError: com/logica/smscsim/Simulator
    And the Simulator.java file is in the com.logica.smscsim. The class path is set.
    Here is a web site that i got this from: http://opensmpp.logica.com/CommonPart/Introduction/Introduction.htm
    Thanks!

    cp is an abbrieviation for classpath java -classpath .... is equivalent to java -cp. In your case, the jars contain the Simulator class. If you opened on with winzip or winrar you would find the Simulator class in com/logica/smscsim folder. It doesn't matter where the jar files are located. The line that you put on there, however, assumes that you are executing the java command from the same folder where the jars are.

  • Pleas help with my music files and folders on an external drive

    A while back, I thought I had a virus on my C drive and was advised to by an external hard drive to move all my important files and folders to. As an inexperienced computer guy, this eventually led to a problem. I have many folders that shouldn't have been moved, main folders that were broken up, duplicates of songs, some song files that are empty, etc. This doesn't just apply to iTunes folders, it includes all the computer's music folders.
    Can you please help me reorganize and delete duplicates (C and external drives)? Is there a quick way to search for song files that will not work? Is there a way to wipe out all iTunes files and start over without losing the songs bought via itunes?

    Welcome to the Apple Discussions. I think you're in the wrong forum. This is the iDVD forum. If I read your question correctly you probably want the iTunes for Windows forum.
    OT

  • Help with Java JAR file opbfuscation.

    I am looking for a free (no $) for use on commercial java code
    code obfuscation program, which can beat the Jode decompiler.
    I have tried Proguard, and I have tried Joga
    (using Jode itself for obfuscation is too complex for my purposes).
    Is there a simple way to beat decompilers like Jode and DJ,
    without a financial outlay if possible,
    given how easy it is to decompile Java bytecode?

    All interesting remarks, everyone!
    Proguard doesn't prevent decompilation on something very small, like a jar
    with one or two classes.
    Proguard is free(no money) for use over commercial java code,
    and is itself a java jar, so it will run on Windows,
    Mac and Linux platorfms.
    It also correctly obfuscates and links external java libraries
    and references to the man jar/class in a very systematic way.
    I'm just wondering if there is something similar to proguard on licensing arrangements,
    working over small amounts of code, and beating
    the decompilers (like Jode).
    I have used the code obfuscation that Dr.Java performs on it's classes during compilation.
    And while the resulting class file tested does confound Jode,
    JD-Gui ("Java decompiler") instantly beats the results of Dr.Java.
    Considering how easy it is to break class files, I was figuring that either Sun
    or another would offer a free/open source/cheap way to secure these class files,
    without resulting to Zelix Klassmaster, and instead of leaving a mess
    of decompiled source code, prevent decompilation of java byte
    code even happening at all?
    Any ideas?
    Edited by: Zac1234 on Jul 5, 2009 10:55 PM

  • Get input from user and create a file and run a script in command line.

    Hi all,
    i'm trying to get a input from user and write it into a file named alpe.jacl
    To get multiple userinputs like address and jobtitle etc etc in the same single window.
    and the code will save the inputs in alpe.jacl one by one in a new line like
    nameis name
    address russia
    jobtitle dev
    So i coded like below.
    Though GUI for user input looks dull Its working fine.
    Now I want this code to perform one more task which is the GUI will contain one more button INSTALL with OK and CALCEL .
    and when after putting all inputs and creating the alpe.jacl file if someone clicks INSTALL it should start ./install.sh script present at the same folder which contains some unix shell commands.
    Here am not able to figure out how to go further...
    One more thing after all the inputs given when I am clicking on the OK button its closing the window instantly which i dont want. I want it like it should wait till someone press CANCEL to exit.
    Please some one help me.
    import javax.swing.*;
    import java.io.*;
    public class file
    public static void main(String []args)throws IOException
    FileWriter ryt=new FileWriter("alpe.jacl");
    BufferedWriter out=new BufferedWriter(ryt);
    JTextField wsName = new JTextField();
    JTextField sName = new JTextField();
    JTextField cName = new JTextField();
    Object[] message = {    "Web Server Name:", wsName,"Server Name:", sName,"Cluster Name:", cName};
    int answer = JOptionPane.showConfirmDialog(    null, message, "Enter values", JOptionPane.OK_CANCEL_OPTION);
    if (answer == JOptionPane.OK_OPTION){    String webserver = wsName.getText();
    String server = sName.getText();
    String cluster = cName.getText();
    out.write("set webservername " +wsName.getText()+"\n");
    out.write("set ClusterName " +cName.getText()+"\n");
    out.write("set ServerName " +sName.getText()+"\n");
    out.close();
    }}Thanks,
    Ricky

    Thanks a lot.
    Is there any way through which i can assign a scroll bar to my panel.
    As when the number of user inputs grows the GUI becomes more bulky and some of the fields are not showing up.
    Cheers
    _Ricky                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Help with delimiters, input files, and mapping scheme

    A node has a name, processing power, neighbors, and cost to each neighbor
    I'm reading this data from an input file:
    node power neighbors cost to each neigbor
    A: 1.1 B, C 4, 5
    B: 2.3 A 4
    C: 3.1 A 2
    I use StringTokenizer to capture each group.
    I place each group in an ArrayList.
    The problem is mapping B,C to their cost from A, etc.
    I have a Node class
    I have a Link class
    I just don't what method to retrieve the neighbors and cost to it's src

    Ok, I'm trying to create a graph
    I'm using an arraylist for the name of nodes, an arraylist for the processing power, and an arraylist for the neighbors and cost. I just don't know how to map the neighbors and cost to name of the nodes.
    Help me!!!!!!!!!
    I created a Node class with a name and processing power, and neighbors
    I create a Neighbor class with a name and cost!
    The data is coming from an input file..............
    I uses and array to allow the user to create as many nodes and neighbors, but I need to get the information on each node. HEEEEEEEEEEELP ME

Maybe you are looking for

  • Mix between MS Outlook Calendar and Mac Contacts - how I got to work

    I've tried to mix my work PC computer with Microsoft Outlook Calendar with my Mac based iPhone. This is how I did it. Can this be done by mobileme? For Now it this works with Outlook over USB. My Microsoft Office Outlook 2003 windows XP within firewa

  • How do I go about upgrading my subscription to DPS Professional? (I'm a Creative cloud member)

    I need to be able to publish an in-app puchase application in app store/itunes. It is for a magazine that will have multiple issues. If I understand correctly I need to have a DPS Professional license.. So, if I'm right how do I go about upgrading.

  • What is wrong please help?

    Hi, I am really confused. I added spry to a registration form on my site. I just loved the way it colors boxes and makes the page come alive if you get me. Sadly this is not the case for me I basically select my textbox for example then add spry text

  • Windows server 2003 DFS problem

    Hi Dear All, I have two domain at two diffrent location i have configured dfs between both domain. but problem is that i have creted two folder but i unable to see daat in one folder i mean data not replicating in one folder. event error 1 The DFS Re

  • Performa 6116CD Startup Problems

    Hi, I tried posting this earlier, however Apple’s discussion web site went down. I have a Performa 6116CD computer that we’ve owned for at least 13 years. It was our first computer. I am trying to get it started so I can use it again, however I am ru