cancel
Showing results for 
Search instead for 
Did you mean: 

Java2Java??

Former Member
0 Kudos

Hello!

I'm a beginner in Java. I have to call one java-program from my java programm ). I have only .class and .java files. How can I do that?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi ,

did u installed ur jdk

if u installed ur jdk set classpath in environment variables .

to run java program

go to ->start-> Run -> type CMD -> enter

u will see command prompt

go to ur workspace

type javac prgname.java

if no errors

type java prgname

it will give o/p

Regards ,

venkat

Former Member
0 Kudos

Thanks!

But I have to call a java program from my java program. Example: first program: myjava.java. In this program I have to call mytest.java program. How can I do that? I have only .java and .class....

Thanks!

Former Member
0 Kudos

hi ,

like thuis we can call another java prg ........

import java.io.*;

public class CallHelloPgm

{

public static void main(String args[])

{

Process theProcess = null;

BufferedReader inStream = null;

System.out.println("CallHelloPgm.main() invoked");

// call the Hello class

try

{

theProcess = Runtime.getRuntime().exec("java com.ibm.as400.system.Hello");

}

catch(IOException e)

{

System.err.println("Error on exec() method");

e.printStackTrace();

}

// read from the called program's standard output stream

try

{

inStream = new BufferedReader(

new InputStreamReader( theProcess.getInputStream() ));

System.out.println(inStream.readLine());

}

catch(IOException e)

{

System.err.println("Error on inStream.readLine()");

e.printStackTrace();

}

} // end method

} // end class

Regards ,

venkat

Former Member
0 Kudos

Hi,

If you want to create object use as follows

public class Myjava{

static public void main(String args[])

{

Mytest test = new Mytest();

}

}

Regards

Ayyapparaj

Answers (0)