Invoke one java application from another?
Hello,
Can anyone tell me how to Invoke one java application from another?
Suppose I have a small java application say, Hello.java which has its own main() method and
I also have another java application, say World.java which has its own main() method too.
What I want to do is invoke or startup World.java from Hello.java.
If possible kindly give code examples?
main is just a normal method so Hello can invoke the main method of World just as it would invoke any other method.
Kaj
Similar Messages
-
Calling Java Application from another
How can i call a Java Application from another java App.
eg., If my Java application is called MyApp and i would like call another java application from within it.
One way could be by using "System". I would like to know if there is any other method and is portable.
Thanks in advance.hi,
it works and not!
if you start an other class with a command like this the 2nd prog/class terminates too if you terminate the caller-class!
dear
oliver scorp -
Not able to execute one Java program from another one via. exec()
Hi,
I am new to this forum, so I might be asking a very trivial quetion.
My program Ap1 is :
class Ap1
public static void main(String a[]) throws Exception
Runtime rt=Runtime.getRuntime();
Process p=null;
p=rt.exec("javac,Pr.java");
Runtime.getRuntime().exec("javac,Pr.java");
When I run the above program, I get below error at the line 7(bold one):
D:\batchwe>javac Ap1.java
D:\batchwe>java Ap1
Exception in thread "main" java.io.IOException: CreateProcess: javac,Pr.java err
or=2
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
at java.lang.ProcessImpl.start(ProcessImpl.java:30)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:451)
at java.lang.Runtime.exec(Runtime.java:591)
at java.lang.Runtime.exec(Runtime.java:429)
at java.lang.Runtime.exec(Runtime.java:326)
at Ap1.main(Ap1.java:7)
Path is set as below(which seems correct):
D:\batchwe>path
PATH=C:\Program Files\Java\jdk1.5.0_05\bin
I am just wondering how to call one Java program from another one?!
Please help.
thanks
RashmiHi diptaPB,
Thanks for your suggestion.
Here is how I tried it again, but not getting the desired output:
Class Pr looks like below -->
class Pr
public static void main(String a[])
System.out.println("hi from process");
When I run 'Pr' from command prompt, i get the desired output:
D:\batchwe>java Pr
hi from process
However, when I call 'Pr' from another program Ap2.java, it seems that it does not call 'Pr':
class Ap2
public static void main(String a[]) throws Exception
Runtime rt=Runtime.getRuntime();
Process p=null;
String[] cmd=new String[2];
cmd[0]="javac";
cmd[1]="Pr.java";
p=rt.exec("cmd");
D:\batchwe>javac Ap2.java
D:\batchwe>java Ap2
************* no output appears here***********************
Looking forward for your help.
regards
Rashmi -
Invoking one web service from another web service
Hi there,
I want to invoke a web service lets say X. But befor sending parameters to this web service, what i want to do is first pass the parameters to a web service called Y and Y will decide wether to call X or not. In other words i want to invoke a web service from another web service.
Its kind of urget so do the needful asap.
ThanksCalling another webservice from within a webservice does not require anything special. The service (say svc1) that calls another service (svc2) will be a web svc client. So you will have to do the same steps for svc1 as you would do for any other web service client
-
Launching a java application from another java application
Hi,
I'm facing an interesting challenge :-)
Inside a Java application, I want to start another java application.
Possible solutions in my list :
1. Using jakarta commons launcher.
2. Runtime.exec (make the code platform dependent).
3. Starting the main method of the other app by create a new Thread inside the current app
4. I know people did this by calling an ant target from the java application but I don't have
any sample code, I appreciate any sample code for it.
Thanks,
Ali SalehiThat is an iteresting challenge :)Don't be mean; he's polite, done some investigation and taken the trouble to be clear. The question, presumably, is "has anyone got a different solution or a preference as to which of these is the best?"
In which case, my advice would be to say that invoking main in a separate thread is fundamentally different from Runtime.exec() because the former would run in the same JVM. Is this what you want? If one app has the other on its classpath then do they need to be separate apps? Could they be modules of a single app? -
Calling a java application from another
Hello,
i have noticed a strange behaviour of my java app when i open it from another java app. When i run the core application with a bat file using jre1.6 everything works fine. Now what i want to do is create an application that checks the existance of jre 1.6, downloads it if it does not exist and run real application with the new jre. The second small app runs with a small jre 1.4.2. In reality it seem to work fine, it downloads the jre1.6 folder and exits normally. However when the real application is launched it behaves strangely without throwing any exceptions. And this behaviour seems to be random. for example, a jpanel may not show any components, or the whole jframe may close suddenly. Does anyone have any idea what is going on? Is there a chance that some classes of the first jre remain in memory and conflict when the second application is launched?Just a wild guess: maybe you're invoking the java 1.6 binaries, but JAVA_HOME or something is pointing to java 1.4 libraries (or vice-versa), and you've found some weird interaction issue.
-
How to call inner class method in one java file from another java file?
hello guyz, i m tryin to access an inner class method defined in one class from another class... i m posting the code too wit error. plz help me out.
// test1.java
public class test1
public test1()
test t = new test();
public class test
test()
public int geti()
int i=10;
return i;
// test2.java
class test2
public static void main(String[] args)
test1 t1 = new test1();
System.out.println(t1.t.i);
i m getting error as
test2.java:7: cannot resolve symbol
symbol : variable t
location: class test1
System.out.println(t1.t.geti());
^There are various ways to define and use nested classes. Here is a common pattern. The inner class is private but implements an interface visible to the client. The enclosing class provides a factory method to create instances of the inner class.
interface I {
void method();
class Outer {
private String name;
public Outer(String name) {
this.name = name;
public I createInner() {
return new Inner();
private class Inner implements I {
public void method() {
System.out.format("Enclosing object's name is %s%n", name);
public class Demo {
public static void main(String[] args) {
Outer outer = new Outer("Otto");
I junior = outer.createInner();
junior.method();
} -
Calling one java program from another
Hello,
How can I start another java program from one? Lets
say I want Second.java to start by calling it from
First.java. How do I do it? The two programs are given
below. Any help is appreciated.
Thanks,
Amanda
First.java
import java.io.*;
import java.lang.reflect.*;
public class First
public static void main(String[] args)
Process theProcess=null;
System.out.println("Hello World from First.java!");
String second=new String("Second.java");
//System.load(second);
//Runtime.getRuntime().load(second);
try
theProcess=Runtime.getRuntime().exec( "Second.java"
System.out.println("after exec");
catch (IOException ioe)
System.out.println(">>IOException thrown in
First.java while calling
Second.java."+ioe.getMessage());
Second.java
public class Second
public static void main(String[] args)
System.out.println("Hello World from Second.java!");
}Thanks, warnerja
What if Second.java is on a remote machine i.e.
First.java and second.java are on different machines?
Will I have to use RMI?Well, you'd have to do some kind of remote invocation. Depends on what kinds of apps house the classes. There are all kinds of ways - web services, servlets, RMI, (maybe others...)
That's a totally different question than what you originally posted, and would have been very relevant to say so in the first place. -
Start java application from another programm
Hi everyboda on this side,
i got a big problem. I would like to start out of MS excel an java programm and I would like to hand over data from the MSexcel programm to the java programm. I hope someone can help me. My idea was to create a batchfile, which I start from the excel-programm to run the java programm, but how do I hand over the data from excel to java?
In advance thanks to all the ones, who tried to help me - maxYou could try to use a JDBC-ODBC bridge that allows you read the data of your excel file.....
Here, a guide for use it:
http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/bridge.doc.html
Hope this helps. -
Is there a way to refer library present in one web application from another
Hi All,
I have two web applications deployed in same server. I have a common library for both web applications so i dont want to duplicate it by putting it in WEB-INF\lib of two web applications.
Is there a way to make it avialble for both application by maintaing the library in one place?
Thanks,
KishoreYou could put it in the common area of your application server, whatever it is. But if it were me, I would just put one copy of the library in each web application. Less scope for classloader problems that way.
-
How to move ADF HumanTask (ADF Project) from One BPM Application to ANother
Good DAy!
Problem
We've created huge Project on ADF with difficult form and now we have to create the same (95%) form in another BPM Application
Is it possible to migrate ADF Project from one BPM Application to Another???Hi,
You can deploy the ADF Project as an ADF Library Jar file and reuse the taskflow from that jar file in another BPM Application. -
Passing data from one bsp application to another
Hi,
I have few queries that most of you would have done in ur projects:
1. I want to pass data from one bsp application to another:
eg based upon selected row of table view which populates material no and descriprion to another application which open the entire material master data.
Now, i have both the pages in diff bsp applications in place but unable to pass the selected material code to the second bsp application.
Had it been two different pages of same application I was able to achieve it with set parameter()
2. To stop the application from reprcessing the data:
eg: Suppose I have a bsp page where user fill details of a customer and on submitinng the details a customer is created in background and the entire page is disabled by my code. Even now if the user press refresh (F5) button then another customer gets created in the background. So basically i want to avoid the reprocess of the onSubmit event
Few lines of sample code would be very helpful.
Best Regards,
Saurabh TripathiHi,
When I am writing the following code in appl1/page1:
export abc from transactionID
to data buffer lv_page_data.
CALL METHOD CL_BSP_SERVER_SIDE_COOKIE=>SET_SERVER_COOKIE
EXPORTING
NAME = 'TRANSACTIONID'
APPLICATION_NAME = RUNTIME->application_name
APPLICATION_NAMESPACE = RUNTIME->application_namespace
USERNAME = ls_name
SESSION_ID = runtime->session_id
DATA_VALUE = lv_page_data
DATA_NAME = 'lv_page_data'
and following code in appl2/page2:
CALL METHOD CL_BSP_SERVER_SIDE_COOKIE=>GET_SERVER_COOKIE
EXPORTING
NAME = 'TRANSACTIONID'
APPLICATION_NAME = RUNTIME->application_name
APPLICATION_NAMESPACE = RUNTIME->application_namespace
USERNAME = ls_name
SESSION_ID = runtime->session_id
DATA_NAME = 'lv_page_data'
CHANGING
DATA_VALUE = lv_page_data
IF lv_page_data IS NOT INITIAL.
IMPORT abc to transactionid
FROM data buffer lv_page_data.
ENDIF.
still the code doesn't work. Please explain and guide
Best Regards,
Saurabh Tripathi -
Copy a publishing page from one Web Application to another
can we copy a publishing page from one web application to another.
If we download a copy from pages library of one web application and upload it to another library of other Web application.
Once uploaded it came up with an error "This page is not using a valid page layout. To correct the problem, edit page settings and select a valid page layout.".It seems like the page layout is missing in target location. Check similar thread below to solve the issue
http://social.msdn.microsoft.com/Forums/en-US/99c24657-0297-4a5c-8600-467bb6ea57d6/this-page-is-not-using-a-valid-page-layout-to-correct-the-problem-edit?forum=sharepointdevelopmentprevious
shipoint.com/2014/03/28/fixing-this-page-is-not-using-a-valid-page-layout-to-correct-the-problem-edit-page-settings-and-select-a-valid-page-layout-error-in-sharepoint-2010/
My Blog- http://www.sharepoint-journey.com|
If a post answers your question, please click Mark As Answer on that post and Vote as Helpful -
Can we call simple a java application from any one of this AS adapters
Can we call a simple java application from any one of this AS adapters?
Prakash
Message was edited by:
user629857You can achieve this using LiveCycle PDF Generator JAVA API. You can find required code here:
Adobe LiveCycle * Quick Start (SOAP mode): Converting a Microsoft Word document to a PDF document using the Java API
In parameters:
//Set createPDF2 parameter values
String adobePDFSettings = "Standard";
String securitySettings = "No Security";
String fileTypeSettings = "Standard OCR";
"Standard OCR" file type setting will run OCR on input pdf. In the code, instead of doc file provide a pdf file. Resultant pdf will be searchable PDF i.e OCRed PDF.
Feel feel to ask any further questions. -
How to pass a "object" as a prameter from one java class to another java
hi experts, I want to know "How to pass and get object as a parameter from one java class to another java class". I tried follwoing code just check it and give suggetions..
import Budget.src.qrybean;
public class ConfirmBillPDF extends HttpServlet
qrybean db = new qrybean();
SimplePDFTable pdfTable = new SimplePDFTable();
pdfTable.simplePDFTableShow("2010","2011","1","2","1","131","102");
}Here i want to pass db with simplePDFTableShow method. simplePDFTableShow is in another java class. So how can i do this.
And also i want to know, how this obj will get.
please help me.
Edited by: andy_surya on Jul 14, 2010 7:51 AMHi andy_surya
what is this i am not understand
pdfTable.simplePDFTableShow("2010","2011","1","2","1","131","102");but i am try to solve your problem try this
qrybean db = new qrybean();
SimplePDFTable pdfTable = new SimplePDFTable();
pdfTable.simplePDFTableShow(db);and access like this in SimplePDFtable class update your method
simplePDFTable(qrybean tempDB)
// write your code
}
Maybe you are looking for
-
I Got my iphone 5 last christmas, and then a couple of months after the charger started to conect and disconect, i thought at first it was just the cord so i bought a new one but then it happened again, from this day i have bought 6 iphone 5 chargers
-
Using FNDLOAD to upload data of all employees into fnd_user form?
Hi I have created a production clone instance. In clone instance, i have to create all users in fnd_user (user form) those exists in HR employees (HR module) for accessing self service application. Each employee in HR will have a fnduser (username=em
-
Hi, i am facing problem in call transaction for fb60. since we have three company code 1000 2000 n 3000. so when we select the company code for change and change it and when press ok then cursor come to vendor account. i did the recording in shd
-
OBI 10g merge 2 time dimensions on the same table/graph in analysis
Hi, My problem is: I have 2 different analyses (working fine) (using OBI 10g), they both use a different time dimension: time_dim_1 | fact1 time_dim_2 | fact2 I want to merge them to have something like the following: time_dim | fact1 | fact2 What I
-
Administrative Boundary Data for Spain
Hi, I have downloaded and installed the SampleApp data, including the Navteq Mapping section. I can use the Map Views provided in the SampleApp demo without problems. I now need to create Map Views in OBIEE that use administrative maps of a particula