Problem with creation of jar with external libraries

hi guys, I've no problem with creation of jar,i use this command:
jar -mcf MANIFEST.MF NameFile.jar *.class
my file manifest is this:
Manifest-Version: 1.0
Created-By: Me
Main-Class: NameFile
Now,I've to make a jar file,but i have to use some external libraries in jar format.
I've read on sun tutorial and i've added to manifest this line:
Class-Path: dt.jar formshelp.jar formsrt.jar jh.jar looks-1.3.1.jar substance.jar TableLayout.jar
But the jar file doesn't work, neither with a double click nor with console...
Someone can help me?Thanks!:)

Darkweb wrote:
sorry but,the external libraries that i use are in .jar,what i've to do to include these libraries in my jar?One of 3 things
1) Take them out of the jar, and put them in a folder, preferably a folder in the same folder as the jar
2) Write a custom classloader to load classes from nested jars
3) Extract the contents of all the dependency jars, and jar them all up with your own code
The first is almost always the most preferable, the second one is doable but brittle and resistent to updating dependencies ( you have to release everything for any changes you need, even if it's not a change in your own code ) and the third one is tedious and suffers from the same robustness problems of the second, not to mention that a lot of software licences prohibit you from actually doing it. Do the first one, it's by far the most common and easiest to maintain. I really wouldn't advise the third option, ever, though. Any activity that reduces the modularity of your application is ill-advised

Similar Messages

  • Problems with creation of JAR file

    Hi!
    I can't succeed in creating a JAR file for my application.
    I've followed the guide at http://java.sun.com/docs/books/tutorial/deployment/jar/basicsindex.html
    but apparently im doing something wrong....
    I've tried doing an extra Manifest file aswell as "Setting an Entry Point with the JAR Tool" as written in the guide. noen with success however :(
    I always get the error "Could not find the main class. Program will exit." from the JVM when I try to run my JAR file.
    Structure of my program:
    C:\searchpath\moresearchpath\projectname\src\
    inside src\ there are 3 packages called; "graphic", "client" and "server".
    I want to make a JAR file from the files in the "server" package. The "server" package consists of these following 4 files(and nothing more); "ClientHandler.java", "TestServer.java", "ServerModel.java", "ServerController.java".
    "TestServer.java" is my main class!
    This is an example of a command I've done in order to try to make a JAR file:
    "C:\searchPathToWhereJavaIsInstalled\jdk1.6.0\bin\jar cvfe sgwserver.jar server.TestServer server\*"
    This doesn't generate any error. However when I try to start the .jar I get following message "Could not find the main class. Program will exit."
    I've also tried creating manifest file manually but without success (with UTF-8 encoding and not double .txt ending on file)
    This is how the "Manifest.txt" file has looked when I've tried making one:
    Main-Class: server.TestServer
    I have used Netbeans 5.5 and Java SE 6 for development
    What am I doing wrong? Please help me :(

    If I try to run the one generated from Netbeans I get the following error message: "Failed to load Main-Class manifest attribute from C:\searchpath\moresearchPath\projectName\dist\projectName.jar"
    The thing is I need 2 JAR files, one that contains the files in the "server" package and one that has all other files. The other one is an applet and the files in "server" package are a standalone application.
    How do I get the standalone application's JAR file to work?

  • Problem in creation of File with random numbers

    hi all,
    i have written a function which generates random num,ber and stores in a text file.
    public static void main(String[ ] args) {
    int count=0;
    System.out.println("Generate Files");
    Random R=new Random();
    File F= new File("C:/e.cartesian");
    try{
    FileWriter fw=new FileWriter(F);
    int c=0;
    int rand=200;
    int l=0;
    for(int i=0;i<3;i++)
    {    for(int j=0;j<5;j++)
    {   for(int k=0;k<80;k++)
    c+=1;
    double d=R.nextDouble()*100;
    Double D=new Double(d);
    int dtoi=D.intValue();
    float itof=(dtoi/(float)100.0)+R.nextInt(200)+l;
    Float f=new Float(itof);
    fw.write(f.toString()+" ");
    System.out.println(f.toString());
    fw.write("\n");
    count+=1;
    l+=200;
    System.out.println("Count==>"+count);
    }catch(IOException e){}
    Problem is , if i run this code with condition k<79 or some other smaller value than 80 it doesnt save any value in text file.

    If you close the file after writing it works: fw.close();

  • Problem in creation of delivery with reff to order

    Dear,
    Experts
    while am creating Delivery with the refference to Sales order that time it is giving a error that is
    Material 51110002 is not defined for sales org. 2000 distr.chann. lang. E.
    Please give some valuable input for which i will solve my problem .
    Susmita

    Hi
    After reading your reply i feel there is some programming debug happening in your system
    See that materials are not getting updated  with the  correct sales orgs and DC combinations in  the proper delivery tables that is in LIKP and LIPS
    Rightnow i dont have access to SAP to guide you further
    In SE16 in both  LIKP and LIPS tables please check whether the material is available in the correct sales org and DC combinations
    Mostly it will not be there
    That is why you are having problem in delivery
    Why delivery tables is not getting updated has to be checked with ABAPer only
    Please try to create another sales order for this material and see whether you are getting this error at order itself
    If in MM01 if the material is extended for the above sales orgs and DC's
    Then again there will not be any error in sales order
    Then we can conclude that there is problem in delivery tables
    Regards
    Raja

  • Problems in creation of activity with the folder relationship...

    Hi People,
    I need to create the activity adding the campaign in the RELATIONSHIP folder.
    To create the activity, I am using the BAPI BAPI_ACTIVITYCRM_CREATEMULTI, but there is the problem: I can´t add the campaign at the folder RELATIONSHIP of transaction CRMD_BUS2000126. Is it possible to create this?
    If not, Is there the other function that do this?
    Thanks,
    Regards.

    Hi Florin,
    At First, thank you for your help.
    Really, I don´t populate the table DOCUMENT_FLOW.
    Sorry, do you have an example to populate this table correctly? Or do you have any documentation about this BAPI?
    Thanks.
    Best Regards.
    Norberto Muramoto.

  • Problem in creation of target with the generated target message

    Hi,
    I’m doing File-to-File content conversion scenario.
    I’m able to see successful message in SXMB_MONI. Target message also created (Request Message Mapping) according the requirement.
    I’m using lastfieldOptional option in source content conversion.
    Adapters are running fine without content conversion failure..
    But the target file is not created.
    Could you pls anyone gives the reason or suggest any other things I need to verify.
    Thanks,
    Venu.

    Hi,
    do you see any errors in adapter <b>message</b> monitor:
    http://hostname:portnumber/MessagingSystem/monitor/monitor.jsp
    Regards,
    michal

  • Object tag not downloading jars with JRE 1.4.2 and above

    Hi All,
    I have a HTML page and following object tag in it:
    <OBJECT id = obj classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH="0" HEIGHT="0">
    <PARAM NAME ="code" VALUE="VIP6.class">
    <PARAM NAME ="archive" VALUE="vipjar.jar,vipserver.jar,powerj.zip">
    <PARAM NAME="type" VALUE="application/x-java-applet;jpi-version=1.4">
    <PARAM NAME="scriptable" VALUE = "true">
      <br>
      <P>
      <H2>The Java 2 plugin is required for this application.  Please call Application Support or the Inventory Hotline<br>
    </H2>
      </P>
    </OBJECT>Above OBJECT tage downloads files vipjar.jar,vipserver.jar and powerj.zip on user's machine when page is browsed using JRE version 1.3.1. But when JRE version 1.4.2 and above is used then the jar's doesn't get downloaded and the application does not find the neccessary class files for execution.
    Please advice what needs to be done so that the object tag runs correctly with JRE version's 1.4.2 and above.
    Thanks in advance for any help.
    Vineet

    Hello,
    Indeed those JAR files are compiled with JDK 1.3. However, the AS Java systems are running 1.4.x, hence, there is no problem to use those JARs with the JRE 1.4. That's why I do not believe your issue is related to the JRE version. In addition, those JAR files do not have 1.4 compiled version.
    Kind regards,
    Tsvetomir
    Edited by: Tsvetomir Tsvetanov on Jun 9, 2009 5:47 PM

  • Is a signed jar with another unsigned jar possible?

    Is it possible to use 1 signed jar with another unsigned jar with webstart. I read this wasn't possible with version 1.0, but what about higher versions? if so how to specify this?
    Thanks
    James
    Edited by: fatbatman on Mar 26, 2009 1:01 PM

    All jars within same jnlp must be signed with the same certificate, but you can use extensions to have many jnlp with different (or no) signature within the same application.
    Bye.

  • Problem in creation of HUs through FM HU_REPACK and HU_POST

    Hi Experts
    This is regarding the problem in creation of HUs with function modules HU_REPACK and HU_POST.
    I am sending two Unique Sources HUs with single destination HU for the same material and batch into HU_REPACK and it shows that it is successfully repacked and soon as the HU_REPACK function module passess I have called HU_POST without any parameters except messages..As the data will be picked up auomatically from the internal memory as these function module are related same function group.
    Even the HU_POST FM passes successfully and also it creates a Transfer order but the problem is that THe HU is created with the MULTIPLE LINE ITEMS for the same material and Batch which should not be done at all .
    Please find the example of the HU created in the system
    0 10020000038479 S-DISP 1 EA S DISPNSARY
    1 0024632192 000004 810062 0.250 KG L0533A4172 Lactose
    1 0024632192 000004 810062 24.900 KG L0533A4172 Lactose
    Material is 810062
    Batch is L0533A4172
    Can you please assist me how to acheive single line item HU when we are trying to repack the data for same material and batch as it does while you create the HU through Manual processing i.e HU02 etc

    Hi Sailaja,
    I have similar requirements like this before with HU_PACKING_AND_UNPACKING FM. It was a tough debugging before I came up with the right solution. Unfortunately, I was not able to document that code..
    But here is what I have been doing.
    Youre on track with the solution below, never use BDC as it will only limit the Handling units that you wish to put into.
    The function modules that starts with V5_ plays important role as you need to initialize the global variables and table of this function group with values before calling HU_PACKING_AND_UNPACKING FM
    Debug inside the Function module, and look for the FM that returns SY-SUBRC <> 0 then set a breakpoint.
    Restart the program then debug inside that FM again (and I do not want to go further on the details, I give you the presumption of literacy)
    You will find some items that has no value, try to initialize everything by utilizing the FM for this function group V51S.
    Happy Debugging.

  • Problem in Creation of Handling Units through HU_REPACK and HU_POST FM

    Hi Experts
            This is regarding the problem in creation of HUs with function modules HU_REPACK and HU_POST.
    I am sending two Unique Sources HUs  with single destination HU for the same material and batch into HU_REPACK  and it shows that it is successfully repacked and soon as the HU_REPACK function module passess I have called HU_POST without any parameters except messages..As the data will be picked up auomatically from the internal memory as these function module are related same function group.
      Even the HU_POST FM passes successfully and also it creates a Transfer order but the problem is that THe HU is created with the MULTIPLE LINE ITEMS for the same material and Batch which should not be done at all .
    Please find the example of the HU created in the system
        0     10020000038479     S-DISP     1     EA          S DISPNSARY
        1     0024632192 000004     810062     0.250     KG     L0533A4172     Lactose
        1     0024632192 000004     810062     24.900     KG     L0533A4172     Lactose
    Material is 810062
    Batch    is L0533A4172
    Can you please assist me how to acheive single line item HU  when we are trying to repack the data for  same material and batch as it does while you create the HU through Manual processing i.e HU02 etc

    *

  • How to use external libraries and JAR files with OpenScript

    Hello.
    I am trying to include ApachePOI, JODATime, and Javamail in my scripts to handle different aspects of our automated performance tests.
    I followed the documentation for Eclipse to be allowed to utilize these external libraries, however, when I attempt to run my tests the classes and methods that are being imported, show up with errors saying that they do not exist.
    I think perhaps that I am using them incorrectly. I cannot see them as script assets, package assets, or project assets using the properties for these items. An error pops up and says those screens are not displaying correctly or display incorrect information.
    If anyone can provide guidance on using these items, that would be great. Right now I'm trying to include them as "previously exported scripts" but I'm not sure that method will work.
    Any advice is appreciated.
    Thanks.
    --tiff                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi Tiff
    For OpenScript 9.* there is an out of the box solution for that, all you need to do in OpenScript go to:
    Script -> Script Properties -> Script Assets -> Add -> jar File ....
    And that is it.
    Alex

  • Problem with external libraries and Web DynPro

    Hello,
    we're stuck here.
    We're trying for a week now to include external libraries(e.g. Hibernate) into our Web DynPro Project, without success so far.
    We read every single forum and blog entry we could find on this topic.
    E.g.: /people/valery.silaev/blog/2005/09/14/a-bit-of-impractical-scripting-for-web-dynpro
    We're running Netweaver 2004s SP9 Trial Version.
    The biggest problem is, that when we deploy an J2EE Server Component Library DC exactly like described in the blog entry above, although it is deployed correctly an lists under Server->Libraries in Visual Administrator, the external hibernate.jar doesn't get deployed onto the server. It's just an empty container named hib/lib without any entries in "Jars Contained". The sda file of the library DC also has only 2K and doesn't include the hibernate.jar which we added as used dc...
    Any help would be greatly appreciated.
    Or is there a simpler way to include external jars into Web DynPro Projects and deploy them to the server? (We already tried putting them into the lib folder without luck, we always get "NoClassDefFound...")
    Edited by: Christian Wieland on Jan 31, 2008 11:22 AM

    Hallo Christian,
    this is a bug which should be fixed in NW 7.0 SP9 patch1: [Look at this forum thread on the same issue: External Library DC in NW2004s SP09|External Library DC in NW2004s SP09].
    Regards, Bertram

  • JavaFX with external libraries

    Hi,
    I would like to get some help about compiling a JavaFX code with external libraries. I've searched around a lot, but cant find the solution.
    Basically I have a JavaFX application, that uses images (they are under the src/ folder as they suggest it) and uses external .jar files, AND these jar files uses other external files (not jars). I want to run the application in desktop mode first, so now I am interested in a solution that makes it work on PC.
    I am using Netbeans to develop and run (works everything fine when running from IDE), and using javafxpackager to compile, when I want to run without the IDE.
    When I compile with Netbeans, the generated jar and jnlp files can run ONLY from the dist/ folder, if I copy it somewhere else in my winchester, it does not start.
    I have find something about "signing jars", so I have to make the jars signed to be able to run them AND to be able to link to the image files that the application uses.
    So I have 2 problems/questions with this situation:
    - I have to use external jars and those jars uses external files, but when I start the app, it seems its __DIR__ variable is not set correctly, but I've read that I have to make the application "signed" to solve this problem, but
    - if I make the JavaFX signed, it requires that all other jars have to be signed? (it sounds logical of course)
    So, my final question is, do I have to make the application (and all other jars) signed, to be able to use external jars and files or not (if I want to run as a desktop application)?
    And if I have to make them signed, then will the relative linking work correctly?
    So whats the best way to make it work (using external files and jars)?
    Thanks for any help, and sorry for the long post (and for my bad english) :)
    Cheers
    kojak

    kojak wrote:
    When I compile with Netbeans, the generated jar and jnlp files can run ONLY from the dist/ folder, if I copy it somewhere else in my winchester, it does not start.Unfortunately JNLP requires the base location to be stored in the JNLP file. While that supposedly makes JNLP distributed stuff more secured, it also make them cumbersome and time-consuming to use.
    Futhermore, JNLP files generated by NetBeans reference a local web server that only runs when NetBeans is on.
    That explains why you just simply cannot move the app to the location you want. I you move them, you have to open them (any text editor) and modify the codebase field (possibly the homepage's href too).
    If you want to use only 1 single JNLP, all your JARs references in that JNLP need to be signed with the very same certificate (certificate A).
    Unfortunately, this is not good most of the time as some external lib (generally the ones coming from Sun/Oracle) are already signed and you cannot resign them.
    The other option is that you can make your main JNLP reference other sub-JNLP that are placed at the same location. Each of these sub-JNLP can reference 1 or more JARs that are signed with a different certificate (1st JNLP used certificate B, 2nd JNLP used certificate C, etc.).
    An example adapted from my own main JNLP:
    <resources>
        <java version="1.6+"/>
        <jar href="http://<intranet web server>/<my main JAR file>" download="eager" main="true"/>
        <extension href="http://dl.javafx.com/1.3/javafx-rt.jnlp" name="JavaFX 1.3.x Runtime"/>
        <extension href="http://<intranet web server>/l2fprod-7.3.jnlp" name="l2fprod-7.3"/>
        <extension href="http://<intranet web server>/JFXtras-0.7.jnlp" name="JFXtras-0.7"/>
        ...and JFXtras-0.7.jnlp:
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="1.0+" codebase="http://<intranet web server>" href="JFXtras-0.7.jnlp">
        <information>
            <title>JFXtras-0.7</title>
            <vendor>JFXtras</vendor>
            <homepage href="http://code.google.com/p/jfxtras/"/>
            <description>Additionnal controls for JavaFX</description>
            <offline-allowed/>
        </information>
        <security>
           <all-permissions/>
        </security>
        <resources>
           <jar href="lib/JFXtras-Common-0.7rc2.1.jar" main="false" download="eager" size="1309380"/>
           <jar href="lib/JFXtras-Controls-0.7rc2.jar" main="false" download="eager" size="1453233"/>
           <extension name="MigLayout-3.7" href="MigLayout-3.7.jnlp"/>
           <extension name="SwingWorker-1.2" href="SwingWorker-1.2.jnlp"/>
        </resources>
        <component-desc/>
    </jnlp>Both JARs files in that particular JNLP can be signed with a different certificate from the one of the main jar, same wit the JARs listed in the 2 sub-JNLPs that are referenced here.
    Note: of course, currently, JARs provided by JFXtras are note signed, so I end having to sign them myself anyway, but you get the idea.
    Unfortunately NetBeans does not generate such setup so you'll have to find a tool or develop something that does that for you.
    Perhaps you should try to post your question in the web start forum Java Web Start & JNLP as well but be prepared to face the all knowledgeable and always helpful but not very user-friendly and definitely not patient with new comers Andrew Thompson.
    Note that I've never used external files so I do not know if signing the JAR would fix that particular issue (I do not think so).
    Overall I do not like Java Web Start, as said before, it's cumbersome, time-consuming to use, poorly documented, with basically very little to no packaging/helper tool, prone to failure if you make the slightest mistake in the JNLP(s) definition (having a nebulous documentation of its feature does not help) and they've introduced a stream of bugs and errors with each sub-release of Java 6 for the past year and the half that makes programmer's life a hell and JWS a joke compared to other deployment technologies used by competitors.

  • Using external libraries over signed Java applet: InvocationTargetException when running locally with 7u51

    We have a signed Java applet that uses external libraries, specifically the OpenOffice application libraries.
    We have a problem running Java applet with 7u51 of "InvocationTargetException" when use these libraries OpenOffice, that is not signed; regardless of the browser used (Mozilla Firefox, Explorer, Chrome).
    Please, as you could solve this problem?   This problem can not arose with 7u40 and earlier..
    Best regards.

    In  java - JRE 1.7.0_51-b13 and signed applet - Stack Overflow found solution. I've missed to add in external jars manifest this: 
    Trusted-Library: true

  • Using external libraries with Developer Studio 7.1 Composition Environment

    Hi,
    I downloaded DS 7.1 CE and tried to develop a simple application which uses an external library.
    I created a development component for "external library" for the local development -> MyComponent, giving it the name "test2" (for the domain basis).
    I imported the external library file using Import -> File System , then selecting the .jar file.
    In the component properties browser I added a public part naming it "mylib2" setting the purpose to "ASSEMBLY" (my intention was that the libarry will be transferred during the deployment to the application server).
    I right clicked on the public part to "managed entities". I selected the archive tree and checked the library file shown there (the one I imported before). #
    Then I opended component properties of my web dynpro project and clicked on "Dependencies". The I chose "Add..." and selected the "test2" development component I created before (see above).
    Then I tried to deploy the project (which uses this external library) using "Deploy Archive and Run"
    After deployment the browser window opens and shows the ClassNotFoundException
    So what did I oversee or do wrong?
    BTW: Is it necessary for using external libraries to use a full fletched NWDI? Or can I use external libs also with netweaver development environments freely available for download on sdn.sap.com?
    Any hints?
    Thanks a lot
    Hannes

    Hannes,
    If you want to use external libraries with DCs then you should follow the NWDI completely.
    Check this step, otheways of using external libraries is mentioned <a href="http://help.sap.com/saphelp_nw70/helpdata/en/e3/de813e77d46245e10000000a114084/frameset.htm">here.</a>
    Regards
    Abhilash

Maybe you are looking for

  • What path to use to access network files from Java app running on Mac

    I have a Java app running on a Mac with OS X that I'm using to check for files that exists on Windows servers within our network. Using a path like /Volumes/<Share>/ works because I've already connected to the drive using Finder. If I try to use a fu

  • IE script to open multiple tabs in quick tab view (control Q)

    First thanks Scripting Guys for all the great information provided by this forum!  I'm using Windows 7 Internet Explorer 8.  I'm looking for a VB Script that when lauched opens multiple webpages in one browser, so each page has it's own tab and I nee

  • SOAP: response message contains an error XIServer/UNKNOWN/ADAPTER.JAVA_EXCE

    Hi , I am getting below error in SOAP reciever channel. Delivering the message to the application using connection SOAP_http://sap.com/xi/XI/System failed, due to: com.sap.engine.interfaces.messaging.api.exception.MessagingException: SOAP: response m

  • Print Dialog broken in iWeb 09

    All I want to do is print a single page from my iWeb site under construction. When the "Print" dialog is used, the preview comes up just fine but when you actually hit the "print" button nothing happens. It's the same for using "Save as PDF" or any o

  • How binding a html page with JSF

    Hi.. I have 2 page html but a need that since my html page load a page JSF... I try but if I only reference the page jsf since my html page occurs a contex error. thank