This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java program that can run a .class file in msdos, is this possible?

 
Rey Fernandez
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys,

I'm going to develop a very simple compiler for a very simple programming language (developed by my Instructor) using java just to illustrate the very basic principles of programming languages. My problem is that i don't have an idea on how a java program execute another java program or how could my program automatically open an ms-dos window and run a .class file on it. I don't even have an idea if this is possible. Any advice?
 
Sohan Badaya
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi you can make a .bat file for this
 
Campbell Ritchie
Sheriff
Pie
Posts: 49466
64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like a job for Superman, no sorry Runtime.getRuntime().exec().

And make sure you understand the problems in the link, and also know about the newer ProcessBuilder class before trying anything.
 
Rey Fernandez
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a batch file? how? if that is possible using a batch file how could my java program run the batch file?
 
Rob Spoor
Sheriff
Pie
Posts: 20555
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With using ProcessBuilder and Process of course. Haven't you followed Campbell's links? Especially the first one is a must-read.

As for opening the MS-DOS window, that is an application called CMD.EXE. Open a command prompt and type "cmd /?" for all options.
 
Rey Fernandez
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you so much guys.....
 
Fred Hamilton
Ranch Hand
Posts: 684
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sohan Badaya wrote:Hi you can make a .bat file for this



This sort of stuff makes me yearn for the good old days of Windows 3.1. Change one line in your buddy's win.ini and you can boot anything heh heh.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic