Java execute .exe file -


i want execute .exe file made c code :

#include <stdio.h> #include <stdlib.h>  void hellofromc(){     printf("hello c!"); }  int main(){  hellofromc();  return 0; } 

currently trying gives me error: not find or load main class test (which class using in java):

import java.io.ioexception;  public class test {     public static void main(string[] args) {         try {             string filename = "d:\\eclipse\\workspace\\testing\\testfile.exe";             runtime rtime = runtime.getruntime();             process p = rtime.exec(filename);         } catch (ioexception e) {             // todo auto-generated catch block             e.printstacktrace();         }     } } 

your questoin been answered in stackoverflow.

could not find or load main class

you can execute executable using processbuilder class in java.

without parameters:

process process = new processbuilder("c:\\executablepath\\testexe.exe").start(); 

with parameters:

pass arguments in constructor itself.

process process = new processbuilder("c:\\executablepath\\testexe.exe","param1","param2").start(); 

Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -