Changeset 836


Ignore:
Timestamp:
06/23/11 16:49:16 (13 years ago)
Author:
vasaie_p
Message:

fix: starting model.exe without the *.dll in executable folder

Location:
trunk/modelicaml/org.openmodelica.simulation.environment/src/org/openmodelica/simulation/environment/filehandling
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/modelicaml/org.openmodelica.simulation.environment/src/org/openmodelica/simulation/environment/filehandling/RunInteractiveSimulationRuntimeEnvironment.java

    r768 r836  
    55
    66import java.io.File;
    7 import java.io.IOException;
     7import java.util.Map;
    88import java.util.Scanner;
    99
     
    5353        try {
    5454            ProcessBuilder builder = new ProcessBuilder(command);
     55           
     56            Map<String, String> env = builder.environment();
     57            String pathFromEnv = "";
     58           
     59            if(env.get("Path") != null){
     60                pathFromEnv = "Path";
     61            } else if(env.get("PATH") != null){
     62                pathFromEnv = "PATH";
     63            } else if(env.get("path") != null){
     64                pathFromEnv = "path";
     65            } else
     66                throw new Exception("path variable not available");
     67           
     68            env.put(pathFromEnv, env.get(pathFromEnv) + ";" + env.get("OPENMODELICAHOME") + "/bin/");
     69           
    5570            builder.directory(new File(pathToExecutable + "/"));
    5671            p = builder.start();
     
    6075            }
    6176//          p.waitFor();
    62         } catch (IOException e) {
    63             System.err.println("IOException starting process!");
     77        } catch (Exception e) {
     78//          System.err.println("IOException starting process!");
     79            e.getStackTrace();
    6480        }
    6581    }
  • trunk/modelicaml/org.openmodelica.simulation.environment/src/org/openmodelica/simulation/environment/filehandling/RunNonInteractiveSimulationRuntimeEnvironment.java

    r641 r836  
    1 /*
    2  *
    3  */
    41package org.openmodelica.simulation.environment.filehandling;
    52
    63import java.io.File;
    7 import java.io.IOException;
     4import java.util.Map;
    85
    9 // TODO: Auto-generated Javadoc
    106/**
    11  * The Class RunNonInteractiveSimulationRuntimeEnvironment.
     7 *
     8 * @author EADS Innovation Works, Parham Vasaiely, Parham.Vasaiely@gmx.de
    129 *
    13  * @author EADS Innovation Works, Parham Vasaiely, Parham.Vasaiely@gmx.de
    1410 */
    1511public class RunNonInteractiveSimulationRuntimeEnvironment implements Runnable{
    1612
    17     /** The path to executable. */
    1813    String pathToExecutable;
    19    
    20     /** The runtime name. */
    2114    String runtimeName;
    2215   
    23     /**
    24      * Instantiates a new run non interactive simulation runtime environment.
    25      */
    2616    public RunNonInteractiveSimulationRuntimeEnvironment(){
    2717        super();
     
    2919   
    3020    /**
    31      * A Runnable thread to execute the simulation runtime.
    32      *
    33      * @param pathToExecutable The folder path to the executable runtime NOTE: complete the
    34      * string without a last slash
    35      * @param runtimeName name of the runtime
     21     * A Runnable thread to execute the simulation runtime
     22     *
     23     * @param pathToExecutable
     24     *            The folder path to the executable runtime NOTE: complete the
     25     *            string without a last slash
     26     * @param runtimeName
     27     *            name of the runtime
     28
    3629     */
    3730    public RunNonInteractiveSimulationRuntimeEnvironment(String pathToExecutable,
     
    4235    }
    4336   
    44     /* (non-Javadoc)
    45      * @see java.lang.Runnable#run()
    46      */
    4737    public void run() {
    4838
     
    5040        try
    5141        {
    52            ProcessBuilder builder = new ProcessBuilder(command);
     42           ProcessBuilder builder = new ProcessBuilder(command);
     43           
     44          Map<String, String> env = builder.environment();
     45            String pathFromEnv = "";
     46           
     47            if(env.get("Path") != null){
     48                pathFromEnv = "Path";
     49            } else if(env.get("PATH") != null){
     50                pathFromEnv = "PATH";
     51            } else if(env.get("path") != null){
     52                pathFromEnv = "path";
     53            } else
     54                throw new Exception("path variable not available");
     55           
     56           env.put(pathFromEnv, env.get(pathFromEnv) + ";" + env.get("OPENMODELICAHOME") + "/bin/");
     57           
    5358           builder.directory(new File(pathToExecutable + "/"));
    5459           Process p = builder.start();
    5560           p.waitFor();
    5661        }
    57         catch(IOException e)
    58         {
    59             System.err.println("IOException starting process!");
    60         }
    61         catch(InterruptedException e)
    62         {
    63             System.err.println("Interrupted waiting for process!");
    64         }
     62        catch (Exception e) {
     63//          System.err.println("IOException starting process!");
     64            e.getStackTrace();
     65        }
    6566    }
    6667   
    6768    /**
    68      * The main method.
    69      *
    70      * @param args the arguments
     69     * @param args
    7170     */
    7271    public static void main(String[] args) {
Note: See TracChangeset for help on using the changeset viewer.