• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Java execute BAT have no response

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am writing a program to execute a .bat to call another java program. The reason is I want to set the JVM heap space to larger. Here's an example I've tried. I am only testing on small files so I haven't put the JVM setting commands in. For now my purpose is to have a copied of the target file when I run the java...

The problem is that when I run the first java to call bat, it only shows the header message, seems it does not run the file properly. The command line hangs and I cannot type any things. By looking at the task panel, I found a new cmd process and java thread is called and I know the code does something, but why this happens? I am quite new to java and hope could have your help. Any ideas what's going on?

Your comments are welcome and appreciate. Thanks indeed.

Here's the code

The Helloworld.java


The bat file, same dir with Helloworld.java


and finally the ResizeImage.java
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your code depends on the Process writing all the stdout first, followed by the std err output. The process may be stuck trying to write to stderr first.

To cover all possibilities, you should be starting two Threads, one to read stdout and one to read stderr. As I recall the javadocs for Process talk about this.

Bill
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic