Results 1 to 9 of 9
- 09-30-2010, 04:27 PM #1
Senior Member
- Join Date
- May 2010
- Posts
- 119
- Rep Power
- 0
how to call 2 java programs in one another java program
Hi
I have written 2 java programs (ie., 2 java projects named school project and census project)
Now i need to write another java program that will give little menu , asking the user what they are trying to do .
Please enter:
1 for school project
2 for census project
In which case you will check for validity and call your appropriate program.
Pls anyone tell me , how to do this in java .
And how to call 2 different projects from another project .
Anyhelp to start off is appreciated.
- 09-30-2010, 04:37 PM #2
What is a "program"?
Everything in java is contained in a class.
I think of a program as a class with a main method that you can start execution of by using the java command. The main method can create and call many other classes. All the classes that are used are part of the "program".
Also you use the word: project. Is this something to do with how to use an IDE?
If so, is there a forum for the IDE you could ask the question on?
- 09-30-2010, 04:48 PM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,422
- Blog Entries
- 7
- Rep Power
- 29
- 09-30-2010, 05:00 PM #4
Senior Member
- Join Date
- May 2010
- Posts
- 119
- Rep Power
- 0
I am trying to understand what you are saying .I am really a basic new java programmer .Learning and doing at the same time.
Can anyone of you , give me a skeleton of code showing me how the third class will call 2 other classes based on the choice of the user.
I wrote 2 projects seperately in eclipse .
Now i want the third project to give a choice to the user to select any one of the 2 projects.
In real world ...it is like this
I as a user should have choice to select either school project or census project to give me the results .
How would i do that in java ..
Pls explain me in detail and i would appreciate , if anyone will give me a skeleton code to explain the choice of choosing from 2 diff projects .
- 09-30-2010, 05:05 PM #5
- 09-30-2010, 05:29 PM #6
Using classes from other projects should work the same way as you use Java's classes.
If needed, import the package and then use new to create new objects of the classes you want to execute.
If the the other "programs" are independent, standalone programs, that expect to be called/started by the java command, then as JosAH says you can start the class by calling its static method: main method. For example:
SchoolProject.main(new String[]{});
A problem will be that the program could call System.exit(0); which will end the JVM for every class.
- 09-30-2010, 05:36 PM #7
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,422
- Blog Entries
- 7
- Rep Power
- 29
- 09-30-2010, 05:45 PM #8
Of course.
One of my projects was something I called ExecJava. It runs a number of my tools in a single JVM using classloaders and a SecurtyManager and whatever else I needed at the time. All my tools can run either standalone or inside this program's JVM.
I was working on a smaller, slower machine when I developed it. The startup time for a JVM was long, so I started one JVM and put all my tools in that one. Besides that was what I had done for a living for many years: Maintained an IBM OS
- 09-30-2010, 07:32 PM #9
Senior Member
- Join Date
- May 2010
- Posts
- 119
- Rep Power
- 0
Similar Threads
-
Is There A Way To Call Another Java Program Within A Java Program
By SwissR in forum New To JavaReplies: 4Last Post: 07-30-2010, 01:25 PM -
Record call trace of a java program and generate UML Sequence Diagrams
By ali_naqvi in forum Java SoftwareReplies: 0Last Post: 04-19-2010, 07:40 PM -
how to call dll file in java program
By santhosh_el in forum AWT / SwingReplies: 6Last Post: 06-12-2009, 10: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, 07:20 PM -
How to call C/C++ Program from Java
By sanjeevtarar in forum Advanced JavaReplies: 1Last Post: 04-17-2008, 09:55 AM
Bookmarks