How to call an external exe program in Java

Source: Internet
Author: User
Topic: How does Java call an external exe program?
Last time: Total reply: 33 pages: 3 [transfer:1 2 3]

[Reply to subject]

How does Java call an external exe program?
Author:TictocShort Message
Reply
I want to use Java to call WinZip and carry the path for batch processing, compression, and decompression.
Who knows how to implement it ???
How does Java call an external exe program?

Reply: How does Java call an external exe program?
Author:StarcraftShort Message
Reply topic: How does Java call an external exe program?


Reply 1 of 33
Reply
Runtime.getruntime(cmd.exe c (cmd)

Cmd is a string representing External commands

Reply: How does Java call an external exe program?
Author:NetycShort Message
Reply topic: How does Java call an external exe program?


Reply 2 of 33
Reply
Check the exec () method of java. lang. Runtime.

Reply: How does Java call an external exe program?
Author:NetycShort Message
Reply topic: reply: How does Java call an external exe program?


Reply 3 of 33
Reply
In addition, JDK has a java.util.zip package that can directly decompress the ZIP file.

Reply: How does Java call an external exe program?
Author:BbccaShort Message
Reply topic: How does Java call an external exe program?
PM

Reply 4 of 33
Reply
So good, I also need it!
Thanks god

Reply: How does Java call an external exe program?
Author:DjluoShort Message
Reply topic: reply: How does Java call an external exe program?
PM

Reply 5 of 33
Reply
Exe files can be called using this method, but other executable files are invalid using this method. Is there any other executable file besides the exe file called by prawns?

Thank you!

Reply: How does Java call an external exe program?
Author:BbccaShort Message
Reply topic: How does Java call an external exe program?
PM

Reply 6 of 33
Reply
Cmd.exe is not can be call by that method

Reply: How does Java call an external exe program?
Author:JockeyShort Message
Reply topic: reply: How does Java call an external exe program?


Reply 7 of 33
Reply
You should not call the system-associated files directly. For example, Jpg is an image file in Windows (opened with the default tool), but it is a different operating mechanism in Unix! Because Java is an exaggerated platform, of course, such API calls cannot be made!

Reply: How does Java call an external exe program?
Author:FairyokShort Message
Reply topic: reply: How does Java call an external exe program?
PM

Reply 8 of 33
Reply
Try this statement.
Runtime hello = Runtime. getRuntime ();
Hello.exe c ("cmd/E: ON/c start winword.doc ");
Specifically, “winword.doc "is the program you want to call. This example calls a Word document.
Remember to store the file in the directory of your corresponding Java class file or provide a relative path

Reply: How does Java call an external exe program?
Author:CoffeadouShort Message
Reply topic: reply: How does Java call an external exe program?


Reply 9 of 33
Reply
No. This method can also be used to call. BAT files.

Reply: How does Java call an external exe program?
Author:DeanYiShort Message
Reply topic: reply: How does Java call an external exe program?


Reply 10 of 33
Reply
Where can I find the commandid of the command string ???

Reply: How does Java call an external exe program?
Author:Blacksun83Short Message
Reply topic: How does Java call an external exe program?


Reply 11 of 33
Reply
Supported ~~~

Reply: How does Java call an external exe program?
Author:VictorxianShort Message
Reply topic: reply: How does Java call an external exe program?


Reply 12 of 33
Reply
In fact, calling exec () in Java is completely out of the Java JVM environment. Therefore, you need to maintain the runtime environment in the future.
Runtime.getruntime(cmd.exe C (CMD)
CMD, it is better to define it as an array cmd [0] = "OS command-c", Windows = "cmd.exe", Linux = "sh"
CMD [1] = "called program + paremeter1 paremeter2 paremeter3... paremetern"
CMD [2] = "other additional requirements", for example, input or output redirection.
CMD [1] = If you call a Java class, you must add the claspath yourself.
CMD [1] = "Java-CP $ classpath:"/home/tomcat/classes ":"/home/tomcat/clases12.jar test pare1 pare2 ...... "in Linux.

How does JAVA call external EXE? Master !!!
Author:Marinely404119Short Message
Reply topic: How does Java call an external exe program?


Reply 13 of 33
Reply
Question 1
When I rewrite testexe. Java to a Servlet and use a link to access the servlet on the JSP page,
In hello.exec())((((((( for example, in the 8th line of program 1, winzip.exe can be executed!
However, an error is reported when a relative path is provided (for example, line 1 in the program !!! The error message is as follows:
Cannot find the winzip.exe file (or one of its components), please make sure that the path and file name are correct, and
The required library files are available. "
I suspect that the Java program and winzip.exe are in the same path,
Once the program runs,
What about servlet errors?

High finger points !!!

Question 2
You can use the specified worker to call .exe. How can I call. bat (for example, startup. bat in tomcat?
I used program 1 in the hello.exe c ("cmd/E: ON/c start d:/jakarta-tomcat-5.0.25/bin/startup. bat");] Call startup. bat error!

The problem is as follows:
The CATALINA_HOME environment variable is not defined correctly. This
Environment variable is needed to run this program.
Hope you can give me some advice !!!!!!

Reply: Why does JAVA call external EXE? Master !!!
Author:Jx7949588Short Message
Reply topic: Question about calling external EXE in JAVA? Master !!!


Reply 14 of 33
Reply
This is what I'm about to do now.

I 'd like to ask
The external commands I want to call Have A Lot Of parameters. Can I use the cmd [] side for trial transfer?

Thank you!

Reply:33, Page:3[Transfer:1 2 3]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.