Problem with creation of a jar file from inside a java program

Hi,
I am trying to create a jar file at runtime from within a java program.
I am able to create a jar file just fine using:
String[] jarArgs = new String[3];
jarArgs[0] = "cvf";
jarArgs[1] = "C:\temp\myjar.jar";
jarArgs[2] = "C:\temp\this";
sun.tools.jar.Main main1 = new sun.tools.jar.Main(System.out, System.err, "jar");
main1.run(jarArgs);However, when I look at the jar it puts the absolute path to the files inside such as:
C:\temp\this\is\my\package\Class.class
instead of only this\is\my\package\Class.class
When running the jar command from the command line it works just fine and I have the relative paths in my jar file.
Does anyone have any experience with this and could help me out?
Thanks in advance
Edited by: mruf on Apr 11, 2008 1:51 AM

Shouldn't jarArgs[2] = "-C C:\temp\this"

Similar Messages

  • Possible to create a JAR file from within a java app?

    Is it possible to create a jar file from within a java application?
    Can it be done more elegantly than by spawning-off another
    process with the Runtime and exec() portions of the api?
    Thanks
    Scott

    Thanks! I was mislead by the API notes for java.util.jar:
    The JarOutputStream class is used to write the contents
    of a JAR file to any output stream.
    I was looking for a class or method to make jar files.
    Seems this is it ;)
    Thanks
    Scott

  • Unable to locate existing  file from unix using java program

    Hi
    I have created a file in unix using java program, file.createNewFile();
    And when i try to search for the same file using file.exists() it is returning false. Paths are correct. Can anybody help me out.
    Thanks & Regards,
    Prasanth

    In Linux FC5 using JDK1.6, this code         File temp = new File(System.getProperty("user.home") + "/abcdefghijklmn");
            System.out.println(temp.createNewFile());prints 'true' and the file is created with length zero.

  • Problem with HelpSet in a jar file

    In our application, the content of the html-pages of the help
    set is not displayed ( the index is ! ) if we put the help set
    in a jar file.
    Withour using a jar file, it works fine.
    The problem appeared with all JavaHelp versions I tried (up to 2.0 beta)
    and using JREs >= 1.3.1_0x. Its funny that it works fine with 1.3.1
    Capitels in the file names are NOT the problem.
    Can anybody help me ?
    Do I have to include somethingh in the MANIFEST.MF file of
    the jar ? If so, what ?

    Check the case of the file names such as map.jhm File names are not case sensitive when in a jar file.

  • Problems with Yahoo, I Cannot download files from my mail or logout from my account.

    Recently, I have discovered that I cannot logout from my Yahoo account without closing Firefox, which clears my history. Also, I have problems downloading files from my email. At first I thought maybe Yahoo was having some issues but when I use Safari, I don't have these problems. Any idea as to what my problem could be?

    I can't think any way in which Adobe Reader is involved in downloading pics from your camera. If you think Adobe is involved, check the name of the Adobe software you are using, they make lots of stuff.

  • How can I execute a  .bat  file from inside a java application

    I have a .bat file which contains an executable file(.exe) and some input and output file names. What commands can I use to execute this bat file from my java application.

    After raeding tkleisas' reply; i am trying to invoke another application (which can be invoked from the command line) by using a batch file and trying Runtime.exec for executing a batch file.
    My current code is:
    Runtime runtime = Runtime.getRuntime();
    Process trialProcess;
    trialProcess = runtime.exec("cmd.exe /C start C:\\guns.bat /B");
    And my guns.bat looks like:
    cd C:\CALPUFF
    echo trial
    start calpuff.exe CALPUFF.INP
    This is not working for me and i get the following in the error stream of the trialProcess:
    Error :
    The system cannot execute the specified program.
    Process finished with exit code 1
    Has anyone come across something like this and know what's wrong with this one??
    thnx

  • Getting the log files from client using java program

    hi
    this is lalita...and i am doing a project in networking.... i am new to socket programming....i have established the socket connection between the client and server...with this site members' help....now i have to get the log files of the client system from the server.... via the created socket....i need it by tomorrow...i.e apr 12th ....as i have to show it to my guide...
    i just need a core java program that will get the log information of the client from the server......
    Can anybody please help me in this regard..... it would be of great help to me and my group....
    Anxiously awaiting for the replies....
    Thanking you and regards...
    Lalita.

    Simple.
    Server is listening on a specific port for the connection from the clients.
    Connect the client with the server on the above mentioned port.
    Open the streams on both side for the connection and run in separate thread.
    Define a protocol for communication between client and server.
    e.g after connection with the server the server send a text message to the client (send log) now the client first should the log file name and size to the sever and then send the file. the server should save the file.
    then disconnect the client or want to get another file or for other tasks define the other commands

  • How to use the google search from inside a java program

    Hi guys
    How can i use google search in my java program?
    What will be the type of the reply i get back from google?
    Thanks in advance
    [http://javamilestone.blogspot.com/|http://javamilestone.blogspot.com/]

    Hi,
    You have here some examples about how to make search on google from a Java application.
    The type of reply is JSON
    Here some documentation about it:
    [http://code.google.com/apis/ajaxsearch/documentation/#fonje|http://code.google.com/apis/ajaxsearch/documentation/#fonje]
    And here some snippets:
    [http://code.google.com/apis/ajaxsearch/documentation/#fonje_snippets|http://code.google.com/apis/ajaxsearch/documentation/#fonje_snippets]
    Regards,
    David.

  • Problem with READ DATASET when reading file from app server

    Hi,
    wondering if anyone can help, I'm using the following code to read from a file on app server, the file is of type .rtf
    OPEN DATASET file_rtf FOR INPUT IN TEXT MODE
                                 ENCODING DEFAULT
                                 WITH SMART LINEFEED.
    DO.
    READ DATASET file_rtf INTO string.
    IF SY-SUBRC = 0.
    EXIT.
    ENDIF.
    ENDDO.
    the open dataset part works sy-subrc = 0, but the read returns sy-subrc = 8 and no data is passed to string.
    Any ideas as to what is causing this problem appreciated, <removed>
    Thanks
    Edited by: Thomas Zloch on Mar 17, 2010 3:57 PM - please don't offer p...

    Hi Adam,
    The source code in the below link has details about how to read/write to application server.
    [Application server file operartions|http://www.divulgesap.com/blog.php?p=NDk=]
    Please let us know if you have any issues.
    Regards,
    Ravi

  • Has anyone had a problem with memory cards switching the file from EOS to EKS?

    My camera memory cards have suddenly switched from an EOS file to an EKS file and are no longer readable.  I don't know if the problem is my computer, my card reader, my memory cards, or my camera.  It doesn't seem probable that two cards would become corrupted or go bad at the same time.  I have two large capacity cards and two new high capacity cards that I haven't tried yet, but I'm afraid to try to use any of my other cards until I know what is going on with these two.   The camera I'm using a 5D Mark II.  Can anyone please help!   This is a serious problem for me! 
    Thank you to everyone for your help and assistance!
    Best regards,
    Windsails

    Lightroom should recognize your camera (assume it's LR3 or later) automatically without pointing it to the DCIM directory. The files you are referring to is system file I think and not the photos; thus OS cannot read the file.
    Do you have a card reader? For some reason, if you connect your camera into Lightroom directly, sometimes LR doesn't show the preview of your images. Instead you'll get ? next to a gray box. If you don't have a card reader, just plug your camera in, ignore the ? and the gray box (this is LR problem, not your camera), then import them anyway. You should see your test shot once it's done importing.
    Weekend Travelers Blog | Eastern Sierra Fall Color Guide

  • Problem with creation of Bank Transfer file by standard Payment Wizard

    Hello,
    I am currently trying to check if the file created by the Payment Wizard is gathering the appropriate data for Bank transfer payment.
    All the steps of the wizard are undergone successfully. However, no file is created or updated.
    Do you have an idea of what would be related to this problem and what could be the solution ? All the bank and accounts information are in the database, so basically nothing is missing as for data.
    Is the path for the file location important ?
    Do I have to create the file before and with an appropriate format ?
    Thank you for your help !
    Francois

    Hi,
    First of all you need to verify that you have allocated a bank file format for the particular payment method. I assume that you have since you are able to successfully generate the payment run. Once you reach the last step which is step 9 of 9 where you are able to print reports carefully observe and locate the bank file icon to the bottom right of the screen. Once you click on that icon you will be able to select the output file location and need to complete the test run successfully whereafter you need to execute the production run. Once the production run has been completed the output file will have been generated.
    Regards,
    Andre

  • Why aren't deployed jar files from forte for java CE recognized by iplanet server?

     

    At 09:33 AM 4/20/01, Rottier, Pascal wrote:
    Forte 4GL is:
    1) A language, TOOL (Compare to Java)
    2) An IDE (Compare to e.g. JBuilder or FJCE)
    3) A collaborative development environment, with central repository (Compare
    to ????)
    4) A distributed application server / object request broker (Compare to J2EE
    servers and/or CORBA)Let's not forget WebEnterprise, Express, and especially Fusion.
    I think, SUN is not al all interested in TOOL.If TOOL were just a language and had no market yet, you are probably
    right. But, not only is TOOL the key to the Forte environment, but it has
    an existing and profitable market. Sun still sells FORTRAN, after all, and
    continues to put money into ADE development for all its language
    products. The real kicker, though, is that I think iPlanet is very clear
    that Fusion, now iIS, is a very key product for them. There may be those
    who wish it were written in Java and who might lobby for doing a Java
    version, but it was clear at the conference that the iPlanet management
    recognize that Java just isn't up to the task at this point. It isn't as
    if all the iPlanet tools are actually written in Java, after all.
    They will only support them for as long as they need.Or, more likely, for as long as they make money.
    Now, in response to Microsofts .NET stratagy. We have yet to see how
    succesfull this will be, but I expect Microsoft to push this down the
    throats of developers and companies quite succesfully.Like they did DCOM?
    =========================================================================
    Thomas Mercer-Hursh, Ph.D email: [email protected]
    Computing Integrity, Inc. sales: 510-233-9329
    550 Casey Drive - Cypress Point support: 510-233-9327
    Point Richmond, CA 94801-3751 fax: 510-233-6950

  • How to use .dbf files zipped into a .zip file from within a java program

    i have a .zip file containing several .dbf files.
    the zip file is automatically downloaded regularly and data from the .dbf files is inserted into the database.
    how do i facilitate automatic extraction of a zip file or how do i fetch data from the .dbf file? (this cannot be done manually)
    anu.

    you could write a little polling class checking the zip file. you can use the java.util.jar package to extract the zip file (http://java.sun.com/docs/books/tutorial/jar/api/index.html). you could also use Jakarta ant (http://ant.apache.org/manual/index.html) to do this job (core task "zip") and call ant's target file on a regular basis (dependend on the OS you use, you can set os tasks/schedules).

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

Maybe you are looking for

  • Unable to load Oracle XML SQL utility

    The following error appears for each java class, when we attempt to load Oracle XML sql utility into Oracle using the oraclexmlsqlload script: E.g. Error while resolving class OracleXMLStore ORA-00904: invalid column name Does anyone know why we woul

  • Wine is taking ages to load

    Wine is taking ages to load in my machine. When i run winecfg, for exemple, it takes about 10min to show me a window. $ winecfg wine: creating configuration directory '~/.wine'... Failed to open the service control manager. -> hangs here for about 10

  • Ipad2 and no sim card

    after 4 visits to the Apple Store in one day, I am still stuck with the same problem.  My iPad 2 does not recognize the SIM card.  Even bought a new iPad 2, brought it home, same or problem.  Tried 3 separate SIM cards and was finally told it was pro

  • Functional module which get triggered after posting of the document F-22

    Hi, I am posting the documents using the transaction F-22. I need to update some table after the documet will get post. I try to find out the BTE'S in the transaction FIBF but unable to find it out. Can anyone help me to find out the relvant function

  • Problem with original Creative Webcam

    Yes i have the original webcam the Pd00 model, and i installed the drivers that i found on this website but they arent allowing me to take pictures with the webcam. it checks to make sure the video is clear it pops up i can see myself fine then it in