aspose file tools*
The moose likes Java in General and the fly likes Copy Jar File Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Copy Jar File" Watch "Copy Jar File" New topic
Author

Copy Jar File

vineet kumar chaudhry
Ranch Hand

Joined: Apr 02, 2011
Posts: 45
Hi All

I wanna copy jar file from one location to another.How will I do that?

I have tried "jar x -C Dir C:\AnyPath\" but it is not working.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41905
    
  63
So you want to use the Windows command line to copy a file from one place to another? That's what "copy" does; what are you trying to achieve using "jar"?

I'll move it to a more appropriate forum.


Ping & DNS - my free Android networking tools app
vineet kumar chaudhry
Ranch Hand

Joined: Apr 02, 2011
Posts: 45
I have a abc.jar(It is used as archive for applet) in my folder vineet.And I a getting the position of vineet folder through getting the enviorment variable(I have set that for it).Now I am using third party api which generates some output in some directory xxx.Now I want my abc.jar in xxx

Can we copy it using ResourceAsStream or something like that ,I just want to copy jar file frome one location to another
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41905
    
  63
So you don't want to do this from the command line, you want to do this using Java code? Searching for "java file copy" or some such term will find code to do that.
vineet kumar chaudhry
Ranch Hand

Joined: Apr 02, 2011
Posts: 45
I just wana do it ,It can be any how
Deep Purohit
Greenhorn

Joined: Mar 29, 2010
Posts: 9

If anyhow copying is ok.. then use the windows "copy".

Process will contain information about the command execution. You can fetch the value from this to know whether execution is success/failed.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

I think the overhead of creating a new process, reading its streams (When Runtime.exec() won't) and waiting for it to exit, will cause this solution to be much slower than any Java-only solution. So just use FileInputStream + FileOutputStream and start copying contents.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Copy Jar File