jira-importer commented on issue #530:
URL: 
https://github.com/apache/maven-javadoc-plugin/issues/530#issuecomment-2957333708

   **[Bert Van der 
Heyden](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=heydenb)** 
commented
   
   I had exactly the same problem and it has indeed nothing to do with 
**UmlGraphDoc** which is a wonderful tool I must admit.
   I assume this is a Windows XP issue which has to do with the fact that 
_Runtime.getRuntime().exec("some command")_ always fails inside the native 
method call.
   
   Anyway, I have found a cure: By building a bat file in the temp directory 
containing the correct command and using the ProcessBuilder class afterwards to 
run that bat file, it works like a charm. It took me a while to find that out, 
but it was worth every second. Those generated UML diagrams are just very cool.
   
   And here is the code for in UmlGraphDoc
   
   ```
   // ...
   private static void runGraphviz(String outputFolder, String packageName,
                String name, RootDoc root) {
   
     File dotFile = new File(outputFolder, (new StringBuilder()).append(
       packageName.replace(".", "/")).append("/").append(name).append(
          ".dot").toString());
     File pngFile = new File(outputFolder, (new StringBuilder()).append(
       packageName.replace(".", "/")).append("/").append(name).append(
          ".png").toString());
     File mapFile = new File(outputFolder, (new StringBuilder()).append(
       packageName.replace(".", "/")).append("/").append(name).append(
          ".map").toString());
     try {
       String[] dotCmdArray=new String[] { "dot", "-Tcmapx", "-o",
          "\"" + mapFile.getAbsolutePath() + "\"", "-Tpng", "-o",
          "\"" + pngFile.getAbsolutePath() + "\"",
          "\"" + dotFile.getAbsolutePath() + "\""};
       StringBuffer dotCmd=new StringBuffer();
       for (int i=0;i<dotCmdArray.length;i++){
          dotCmd.append(dotCmdArray[i]);
          dotCmd.append(" ");
       }
                
       String cmd=dotCmd.toString();
       String tmpBatFile=System.getenv("temp") + "/rundot.bat";
       try{
          BufferedWriter out=new BufferedWriter(new FileWriter(tmpBatFile));
          out.write("echo off\n");
          out.write(cmd);
          out.close();
       }catch(IOException e){}
   
       List<String> command = new ArrayList<String>();
       command.add(tmpBatFile);
       command.add("/A");
   
       ProcessBuilder builder = new ProcessBuilder(command);
       Map<String, String> environ = builder.environment();
       builder.directory(new File(System.getenv("temp")));
   
       final Process process = builder.start();
       InputStream is = process.getInputStream();
       InputStreamReader isr = new InputStreamReader(is);
       BufferedReader br = new BufferedReader(isr);
       String line;
       while ((line = br.readLine()) != null) {
           //System.out.println(line);
       }
       //System.out.println("Program terminated!");
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
   //...
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to