aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes java program that can run a .class file in msdos, is this possible? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "java program that can run a .class file in msdos, is this possible? " Watch "java program that can run a .class file in msdos, is this possible? " New topic
Author

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

Rey Fernandez
Greenhorn

Joined: Aug 06, 2009
Posts: 10
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

Joined: Feb 16, 2008
Posts: 1
Hi you can make a .bat file for this


sohan
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38765
    
  23
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

Joined: Aug 06, 2009
Posts: 10
a batch file? how? if that is possible using a batch file how could my java program run the batch file?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19693
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Rey Fernandez
Greenhorn

Joined: Aug 06, 2009
Posts: 10
thank you so much guys.....
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: java program that can run a .class file in msdos, is this possible?