Zip command-line in Java

Any1 know how to use the win-zip commandline add-on from within a java program. Or how to execute any commandline arguments?
Any help would be apreciated
Amir

Thanks alot you all !
With a little check in the pitfalls it solved the problem.
You can also use ZipInputStream/ZipOutputStream to read/write zip >files if you want a pure Java solution.
Rick You know of anyway to password protect a zip file with a pure java solution Rick ? Cause it would probably be the best solution.
Thanks again !
Amir <hates to be a n00b>

Similar Messages

  • How to make system call to execute command line in JAVA?

    Hi,
    I am new in JAVA. How to make system call to execute the following command line in JAVA in LINUX environment.
    rpm -qa jdkIn C programming, use as such:
    system ("rpm -qa jdk");
    How about JAVA?
    Thanks.

    Runtime.getRuntime().exec. But first read this:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • Running a command line in Java

    Dear all,
    I have a question, I need to run a command line in a Java program. The commands line is the next:
    cas.exe -i file1
    I have been seeing in internet and I have tried:
    Process ls_proc = Runtime.getRuntime().exec("cmd /c start D:\\cas>cas.exe -i file1");
    it start the window where the cas folder is... but it dont run the commands line : cass.exe -i file1 :(
    Somebody can help me, please??
    Andrea

    try running it like this.
    Process ls_proc = Runtime.getRuntime().exec("cmd /c start D:\\cas>cas.exe -i file1" +"\n");
    if that does not work put this underneath the original.
    ls_proc.newLine();
    or look into the ProcessBuilder class in java.lang.

  • Compressing a large PDF document using command line or Java code without GUI operations

    hi,
    I have a programatically generated very large PDF file with lots of tables and cells in it. The size of the file is few MBs. Using Adobe pro, I am able to reduce the size of the PDF in KBs. I want to achive it either through a command line or using Java API without GUI interaction.
    I am using JDK1.6.
    Thanks.

    I think you need the scripting or SDK forums http://forums.adobe.com/community/acrobat
    As far as I know, Acrobat does not have command line operation

  • Command Line Build - Java heap space error

    I'm attempting to build a Flex app via the command line. Even though the build works fine from within the Flash Builder IDE, I get the following error when I attempt to build via the command line
    C:\code\software\web_stuff>"C:\Program Files\Adobe\Adobe Flash Builder Beta 2\FlashBuilderC.exe" --launcher.suppressErrors -noSplash -application org.eclipse.ant.core.antRunner -data "C:\code\software\web_stuff" -file C:\code\software\web_stuff\build.xml WebControlBrowser
    Buildfile: C:\code\software\web_stuff\build.xml
    WebControlBrowser:
    [fb.exportReleaseBuild] Compiling 1 application to C:\code\software\web_stuff\WebControlBrowser\bin-release...
    [fb.exportReleaseBuild] Exception in thread "Code Model Worker" java.lang.OutOfMemoryError: Java heap space
    [fb.exportReleaseBuild]         at org.eclipse.core.internal.runtime.InternalPlatform.getLog(InternalPlatform.java:404)
    [fb.exportReleaseBuild]         at org.eclipse.core.runtime.Plugin.getLog(Plugin.java:282)
    [fb.exportReleaseBuild]         at com.adobe.flexbuilder.codemodel.internal.bridge.WorkspaceSpecification.log(WorkspaceS
    pecification.java:136)
    [fb.exportReleaseBuild]         at com.adobe.flexbuilder.codemodel.internal.parsing.ASTokenizer.parseTokens(ASTokenizer.
    java:386)
    [fb.exportReleaseBuild]         at com.adobe.flexbuilder.codemodel.internal.search.SWCSearchDataProvider.indexFiles(SWCS
    earchDataProvider.java:440)
    [fb.exportReleaseBuild]         at com.adobe.flexbuilder.codemodel.internal.search.SWCSearchDataProvider$2.run(SWCSearch
    DataProvider.java:364)
    [fb.exportReleaseBuild]         at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    [fb.exportReleaseBuild]         at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    [fb.exportReleaseBuild]         at java.lang.Thread.run(Unknown Source)
    BUILD FAILED
    C:\code\software\web_stuff\build.xml:4: java.lang.OutOfMemoryError: Java heap space
    Total time: 1 minute 0 seconds
    FlashBuilderC:
    An error has occurred. See the log file
    C:\code\software\web_stuff\.metadata\.log.
    I've attached the .log file that is referenced.

    Why isn't this documented somewhere? or if it is why isn't it easy to find?
    This link ought to have a link to common issues people run into.
    I just spent an hour trying to solve this same problem. FlashbuilderC.exe wouldn't even work on very small projects until I found this post, so thanks.

  • To execute command line from java programmin

    Hi,
    I need to execute a command line like ping command from java applications can any help me on this. Thanks in advance.

    Runtime.exec
    Also read: When Runtime.exec() won't: Navigate yourself around pitfalls related to the Runtime.exec() method

  • Execute command line from Java

    I have an easy one for you!
    I would like to know how I can execute a command line from my java code.
    The only thing I want to do is to launch a html page with the default browser in my computer when I press one button of my java application but I dont know wich class I should use to do it. My application will already know what is the file name.
    Thank for your help
    Eric

    Javaworld has some source code that does this:
    http://www.javaworld.com/javaworld/javatips/jw-javatip66.html

  • How to include a parameter executing a command line from java??

    Hey
    I've a problem It's very single for you: this consists in execute a command from java
    in this case the command is : runas but I've tried nd is good but I can´t include the password.
    This is due to the sintaxis is :
    runas /user:127.0.0.1\Administrator cmd
    The first command is execute but.. the problem is it show the input for the password.
    And the password is not let including in the command line
    How can I do that? Please help me is very urgent.
    Any help will be very appreciated.
    Thanks in advance.
    Best Regards.

    DAnt. wrote:
    what is the name of the correct forum which I must visite? this is because I couln't found the correct forum.You will not find it on the Oracle website
    I expect your prompt reply,help me!http://tinyurl.com/yak89nc

  • Execute external java command line in Java

    But I can not get any result ( It does not create file test.svg) . the code is as follow
    Runtime.getRuntime().exec("java -jar c:/XSLT/saxon7.jar ../webapps/wfscontroller/gml.xml ../webapps/wfscontroller/SVG.xsl > ../webapps/wfscontroller/test.svg");
    If I execute "java -jar c:/XSLT/saxon7.jar ../webapps/wfscontroller/gml.xml ../webapps/wfscontroller/SVG.xsl > ../webapps/wfscontroller/test.svg" in DOS command. it works.
    Anybody knows what happened?
    Many thanks in advance.

    The > is interpreted by the shell. When you use Runtime.exec, you don't go through the shell, you exec the executable directory. So when you exec that command, you're passing ">" as an argument to "java -jar c:/...", and chances are the main() method in that doesn't interpret ">".
    So the upshot is you can't use ">", "|", "<", etc., that you can in a shell, with Runtime.exec().
    Other options are to run a batch file which invokes that command line.
    Or, you can get the standard output from the exec'ed process, and save it to a new file yourself.

  • How to execute command line by Java

    Hi all,
    I have the following DOS command line that I need to execute it through Java:
    C:\Documents and Settings\Mxmler\Desktop\bin>vr1tovr2 Box.wrl -o Box2.wrl
    I know that I have to use Runtime.getRuntime().exec, But can anyone show me how to use it for the above?
    Thanks

    Mxmler wrote:
    I need your help please
    Forget about the first thread
    vr1tovr2 located inside a sub directory called converted (not in the main directory of the project constructed by eclipse)You have to tell the system where to find the program you're trying to run. You can specify the full path to the executable. Alternatively, you can specify the PATH environment variable when you call exec() (and I presume there's something similar for java.lang.ProcessBuilder). Read the docs.
    Box.wrl & Box2.wrl (will be generated) both of them are located in another directory called usrYou can either specify full paths to those files, or you can set the current working directory when you call exec(). So you'd tell exec() that you're in the directory where those files are. Read the docs.
    I have tried to do the following and I got the following error message: CreateProcess error=2, The system cannot find the file specifiedYou need to do what I said above, in particular, the first one (where you tell the system where to find the program you're trying to run).
    String path = System.getProperty("user.dir");
    String userFolder = "usr";
    String fileName = "mxmler";
    String extension = ".wrl";
    Runtime.getRuntime().exec("vr1tovr2 "
                + Key.QUOTE
                + path
                + Key.FORWARD_SLASH
                + userFolder
                + Key.FORWARD_SLASH
                + fileName + extension
                + Key.QUOTE
                + " -o "
                + Key.QUOTE
                + path
                + Key.FORWARD_SLASH
                + userFolder
                + Key.FORWARD_SLASH
                + fileName + "v2" + extension
                + Key.QUOTE);If you're going to break it down like that, then don't use the version of exec() that takes a single String for the whole command line. Use the version of exec() that takes an array of Strings (the first String in the array is the program to run, and the remaining strings in the array are arguments to that program).

  • Help Please: How to invoke unix command lines from java?

    I have read past topics. Those are really helpful, but I still haven't got my job done. I tried the following:
    String command1 = "ls -la > ls1.txt";
    Runtime.getRuntime().exec(command1);
    String command2 = "tcsh -c ls -la > ls2.txt";
    Runtime.getRuntime().exec(command2);
    String command4 = "cp keywords.txt copyversion1.txt";
    Runtime.getRuntime().exec(command4);
    String command5 = "tcsh -c cp keywords.txt copyversion2.txt";
    Runtime.getRuntime().exec(command5);
    String command6 = "tcsh -c 'cp keywords.txt copyversion3.txt'";
    Runtime.getRuntime().exec(command6);
    Only "command4" works. Any input will be greatly appreciated.

    Thank you very much Gautam. Your solution certainly works. If you don't mind, I would like to ask you (or anybody who is willing to answer) something else. I am trying to run other types of unix command lines as well. I thought that the format you gave would work for everything. But it doesn't seem so:
    String command1[] = {"tcsh", "-c", "ls -la > ls1.txt "}; // this works as you suggested
    Runtime.getRuntime().exec(command1);
    String command12[] = {"tcsh", "-c", "lynx -dump http://www.yahoo.com > webpage.txt"}; //working fine.
    Runtime.getRuntime().exec(command12);
    String command10[] = {"tcsh", "-c", "ngram-count -text keywords.txt -lm LM10 &"}; //doesn't work
    Runtime.getRuntime().exec(command10);
    String command[] = {"tcsh", "-c", "/u/drspeech/sun4/bin/ngram-count -text keywords.txt -lm LM0 &"}; // doesn't work
    Runtime.getRuntime().exec(command);
    String command13[] = {"tcsh", "-c", "ngc -text keywords.txt -lm LM13"}; // doesn't work
    Runtime.getRuntime().exec(command13);
    String command8 = "ngram-count -text keywords.txt -lm LM8 &"; //doesn't work
    Runtime.getRuntime().exec(command8);
    String command9 = "/u/drspeech/sun4/bin/ngram-count -text keywords.txt -lm LM9 &"; //doesn't work
    Runtime.getRuntime().exec(command9);
    I tried "commandd1" and "command12". Those worked fine. No problemo. However, there's someting else I need to get done for my job; that is "command10". But it just didn't work. I thought maybe, it's because "ngram-count" is not part of the standard UNIX commands. So, I thought I might just add another alias for it in the ".cshrc" file and call it "ngc" instead. Then I tried to call the alias "ngc" instead. But it didn't work also. Then I thought, maybe, I should call it by referencing it from its original directory "/u/drspeech/sun4/bin/ngram-count". That didn't work either. I tried a couple of other combinations. None worked. I would really like to see how to solve this.

  • Running a windows command line in java?

    Hi guys.
    I wonder if there's a way to run windows (dos) commands from within java. the code goes like:
    if (setting == true) {
    run dos command "ECHO Command is activated and running."
    please reply if you are able to help out. thanks a lot
    - n3phi|im`

    note that in some cases you can use a normal
    Runtime.exec ("program arg1 arg2");
    but in some cases the commands are built into the shell, so you have to do
    Runtime.exec ("command.com /c copy myfile here");
    "copy" is one of them, and "echo" is probably one too. The latter should work for all programs and commands, but might involve some overhead as a new instance of 'command' is created and destroyed for every command.

  • Using Unix command lines in java code

    I was wondering if there was a way to run a unix command in java code. I know in C++ there is popen, but i don't know of a way in java. The command i need to run is the whois "domain name" command. Any help would be great!
    jarad

    try something like this:
      public static String whois(String domain) throws IOException {
        BufferedReader is = null;
        Process p = null;
        String result = "";
        p = Runtime.getRuntime().exec("whois " + domain);
        is = new BufferedReader(new InputStreamReader(p.getInputStream()));
        String line;
        while((line = is.readLine()) != null)
          result += line;
        return result;
      }

  • Calling linux command line in Java

    Hi guys,
    I met a problem about calling linux comand in java program.
    In linux, I type :
    similarity.pl -type WordNet::Similarity::vector -file /home/csunix/fzsu/exam.txt
    it returns:
    Loading WordNet... done.
    Loading Module... done.
    good#a#1 nice#a#1
    good#a#1 nice#a#1 0.885813537770033
    dog#n#1 cat#n#1
    dog#n#1 cat#n#1 0.712603873475428
    good#a#6 nice#a#1
    good#a#6 nice#a#1 0.822428178005622
    From above, we can see that it works well, similarity.pl is a perl program for computing similarity between two concept, and -type and -file are the parameters.
    Now I want to use java to call these command, and here is my code:
    public static void main(String[] args) {
    try{
    String command="similarity.pl -type WordNet::Similarity::vector -file /home/csunix/fzsu/exam.txt";
    Process p=Runtime.getRuntime().exec(command);
    BufferedReader br=new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line=null;
    while ((line=br.readLine())!=null){
    System.out.println(line);
    }catch (IOException ex){
    ex.printStackTrace();
    But noting is print out. I also add the full path for similarity.pl, like /home/csunix/fzsu/similarity.pl in the variable "command", but still the same.
    I also change variable "command" to a string array in this way:
    String command[]={"/home/csunix/nlplib/WordNet/2.1-F7/perl/bin/similarity.pl",
                        "-type","WordNet::Similarity::vector","-file","/home/csunix/fzsu/exam.txt"};
    Again, I get nothing from it.
    Can anyone point out how to solve this problem?
    Thanks,
    Joe

    Crosspost.
    Don't do this if you want help!
    This question is answered on "New to Java".

  • Invoke a command-line from java

    Hello!
    I wonder if there' s a way to invoke a command or running an .exe file from java code.
    10X,
    Yaron

    Sure, using the exec method in the class Runtime. You have to be careful with it though...
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

Maybe you are looking for

  • Regarding vendor creation

    While creating new vendor in xk01 IDES. it is going to dump. and i even 1000 company code i am creating. still its going to dump. and it is givining below message: When exporting the structure description, the structure components overlapped. The err

  • How i remove the stand from an Intel iMac 17"  ???

    Please help...is it possible to remove the stand from an intel based imac 17" . If yes how i do it? Thank you

  • USB in Java

    So there is an API for linix, but what about windows? I'm trying to find anything on the use of USB through java. I've got a palm pilot I'm trying to communicate with. I'm finding theories and low level USB info, but java info on USB's whimper

  • Functional module extractor for INDX

    Help to write please an optimum code of the functional module for an extractor from table INDX

  • Application Lifecycle management

    Supose application A (a sort of application manager) starts application B. After some time the user exits application B, and B destroys itself by calling destroyXlet. Is it then still possible to start application B from within A or will the user nee