[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.4

Two problems on running a program from another using Process class

Asked by Iaskyou in Java Programming Language, Apple Programming, Microsoft Windows Operating Systems

Tags: java, class, program, another, process

Dear:

I met two problem when running a process using Process class.

My Java program called Program-A,  needs to run another Java program called Program-B as a sub-process. P-A needs to run P-B. My solution is to make P-A compily P-B and then runs the entry class file of P-B.  When running, P-A add "bin" directory of P-B into CLASSPATH variable to guarantee that "java" command can find the entry class of P-B under its "bin" directory. Then P-A use Process class to run the command "java -classpah ..."Main" to run P-B from Main.class.

The first problem occurs when updating CLASSPATH variable. We know that the value of CLASSPATH is a combination of several directory names that are separated by ";" under Windows, or separated by ":" under MacOS, or by another character under other OS'. My program need to run under different OS'. Is there an appropriate way to obtain the separating character of CLASSPATH variable from some system variable, so I don't need to detected the OS when updating CLASSPATH every time.

The second problem is about the execution of a .class file. The entry class of P-B is Main.class. P-A runs it using java command. But the command I used under MacOS can not work under Windows. The same case happens under Windows. The command I use under MacOS is:

                /* for macos.  This command does not work under Windows*/
            String[] cmd = {"java",  "Main", "0"};
            String[] env = {"CLASSPATH=" + strClsPath};
            Process ps = Runtime.getRuntime().exec(cmd, env, new File("ProgramB/bin/"));
         


The comnand under Windows is

  /*   for win os. This command does not work under MacOs. */
            String strCmd = "java \"-classpath\" \"" + strClsPath + "\" \"Main\" 0";
            Process ps = Runtime.getRuntime().exec(strCmd);

Does someone know the appropriate format of command that can be used under all OS'.

A further question is about the solution. Is there a better solution for P-A to run P-B?
[+][-]04/26/07 05:01 PM, ID: 18986064Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]04/26/07 05:04 PM, ID: 18986084Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]04/26/07 05:04 PM, ID: 18986088Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]04/26/07 05:06 PM, ID: 18986094Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]04/27/07 01:20 AM, ID: 18987308Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]04/27/07 06:32 AM, ID: 18988784Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/27/07 06:51 AM, ID: 18988932Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]04/28/07 01:53 AM, ID: 18993896Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/28/07 01:58 AM, ID: 18993904Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Java Programming Language, Apple Programming, Microsoft Windows Operating Systems
Tags: java, class, program, another, process
Sign Up Now!
Solution Provided By: objects
Participating Experts: 3
Solution Grade: B
 
[+][-]05/11/07 09:49 AM, ID: 19073519Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81