• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can I get Java to call external program to do work  RSS feed

 
Tuan Phuong Le
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

Can anyone help me on how to code in Java to call an external program such as mspaint.exe. I have over 1500 bitmap files, 10MB each, that I have to manually open using mspaint.exe, then perform a "Save As" in jpeg to reduce its file size. Can I do this through Java?

please help. A few lines of code should be helpfull.

Thank you in advance
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all, welcome to the Ranch! You can run an external executable from your Java program using ProcessBuilder or System.exec(...) but I don't think there's any way you can instruct MSPaint to "Save As..."

But what you want, opening a .BMP and saving it as a .JPG can be done in Java, without need for any external program. Read the API for ImageIO.

A few lines of code should be helpfull.

You first ;)
 
Tuan Phuong Le
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First thank.

I did find some sample from the web using ProcessBuilder, System.exec(...), but that just invoke mspaint.exe. You mentioned using API by ImageIO. Will this resize from .BMP to JPG to a smaller size file? I am doing some research on this, but also look forward to see your response.

Thank.
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you try it and find out? It will only take a couple of minutes and you'll learn much more from it.
 
Balaji Ashokkumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the code for your need...
 
Tuan Phuong Le
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank alot Balaji.

 
Balaji Ashokkumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome Tuan...
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!