Results 1 to 5 of 5
- 07-30-2010, 10:35 AM #1
Member
- Join Date
- Jul 2010
- Posts
- 39
- Rep Power
- 0
Is There A Way To Call Another Java Program Within A Java Program
Hi everyone,
I basically have two Java programs and am wondering if i can complete my first programs run and then call my second program within the first like calling a css file in html.
I dont really want to have to add the class of one program to the other and fiddle around with it. I know I can call them in the command prompt window but if possible I would like to execute them both through one instance if possible.
regards S
- 07-30-2010, 11:19 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,406
- Blog Entries
- 7
- Rep Power
- 17
That implies that both classes have a main( ... ) method; why not call that method yourself? e.g.
Note that I didn't pass any arguments to the main( ... ) methods; you decide whether or not that is correct.Java Code:YourFirstClass.main(null); YourOtherClass.main(null);
kind regards,
Jos
- 07-30-2010, 11:27 AM #3
Member
- Join Date
- Jul 2010
- Posts
- 39
- Rep Power
- 0
Im a little confused by what you mean.
So your saying that I can call the class and main method of one program within another without actually having to paste the class into said program?
I mean im calling one program via its main class so do I call the other programs class and then its main method through that...
I would have thought I would have had to reference a directory, or am I getting the wrong idea here...?
regards S
- 07-30-2010, 11:50 AM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,406
- Blog Entries
- 7
- Rep Power
- 17
Yes.
Yes.
Yes. There's nothing special about a main( ... ) method; if the jvm can call it, you can call it as long as the class is visible to the jvm; but it has to be because you wrote in your OP that you can call the class (through its main( ... ) method) from the command line.
kind regards,
Jos
- 07-30-2010, 12:25 PM #5
Member
- Join Date
- Jul 2010
- Posts
- 39
- Rep Power
- 0
Similar Threads
-
Record call trace of a java program and generate UML Sequence Diagrams
By ali_naqvi in forum Java SoftwareReplies: 0Last Post: 04-19-2010, 06:40 PM -
how to call dll file in java program
By santhosh_el in forum AWT / SwingReplies: 6Last Post: 06-12-2009, 09:23 PM -
Is it possible to make a Phone call program using java?
By fireball2008 in forum New To JavaReplies: 2Last Post: 05-08-2008, 06:20 PM -
How to call C/C++ Program from Java
By sanjeevtarar in forum Advanced JavaReplies: 1Last Post: 04-17-2008, 08:55 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks