Use ProcessBuilder to execute a java program with a file piped as input
Hi,
I am trying to execute a java program passing in input file as argument. I have to do this by forking a process and am using Processbuilder.
I have a main function which calls the executeCliTopologyDesigner method. I get a Java I/O exception
Caught IOException: Cannot run program "$JAVA_HOME/bin/java oracle.apps.fnd.provisioning.cli.TopologyDesigner ": java.io.IOException: error=2, No such file or directory
Can you please let me know if I am missing something?
Thanks,
pkrish
Code Snippet:
private synchronized void executeCliToplogyDesigner(String cliCommand, File tmp)
throws IOException, InterruptedException
{ File temp= writeDataInTemp(compDefName);
cliCommand = "$JAVA_HOME/bin/java oracle.apps.fnd.provisioning.cli.TopologyDesigner ";
ProcessBuilder pb = new ProcessBuilder(cliCommand,"<",temp.getCanonicalPath());
executeProcess(pb);
Edited by: pkrish on Mar 2, 2009 3:56 PM
Edited by: pkrish on Mar 2, 2009 3:57 PM
Edited by: pkrish on Mar 2, 2009 3:58 PM
Edited by: pkrish on Mar 2, 2009 3:59 PM
Hi,
I printed out the system environment variables PATH and CLASSPATH and it is as below:
Classpath :/ade/prprasa_prov_latest/fmwtest/tools/orajtst/home/lib/orajtst.jar:/ade/prprasa_prov_latest/jdev/src/abbot/dist/EXTENSIONS
Path :/ade/prprasa_prov_latest/fxtn/util/tools/ant/bin:/ade/prprasa_prov_latest/fmwtest/tools/orajtst/home/bin:/ade/prprasa_prov_latest/oracle/jdeveloper/jdev/bin:/ade/prprasa_prov_latest/javahome/jdk/bin:/usr/kerberos/bin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/usr/local/ade/bin:/OracleProd/oracle10g/bin:/OracleProd/oracle10g/bin:/OracleProd/oracle10g/bin
The Path does contain java.
I changed my command as I need a different classpath.
cliCommand = "/ade/prprasa_prov_latest/javahome/jdk/bin/java -classpath .:/ade/prprasa_prov_latest/oracle/provisioning/tools/lib/*:/ade/prprasa_prov_latest/oracle/provisioning/configframework/lib/*:/ade/prprasa_prov_latest/oracle/provisioning/framework/lib/*"
Caught IOException: Cannot run program "/ade/prprasa_prov_latest/javahome/jdk/bin/java -classpath .:/ade/prprasa_prov_latest/oracle/provisioning/tools/lib/*:/ade/prprasa_prov_latest/oracle/provisioning/configframework/lib/*:/ade/prprasa_prov_latest/oracle/provisioning/framework/lib/*": java.io.IOException: error=2, No such file or directory
Any ideas? Please let me know where do I post it if not here.
Similar Messages
-
Batch prog to execute remote java program
hi all
i have one batch file which executes the local java program ....
but i want to execute a java program in a remote machine....
how do i do this..? kindly helpWell this is what I do in Windows (I use XP but it works in others):
First you have to make sure all the class files are in the same folder (duh)
Then you copy your java.exe from your jre folder into the folder with all your class files.
Finally, you create a shortcut to java.exe and add your class name to the command line on the shortcut.
Now all you have to do is double click on the shortcut and your program runs. Sure it's not that pretty but it works. -
How to execute a java program by clicking !?!?
Just a click to execute a java program?!!
Like the ".exe" in Windows or "x" permission in Unix ?!?!?!
How can I do that?
And how to set a java program file to display as a personal icon? (My Icon)
:-)Well this is what I do in Windows (I use XP but it works in others):
First you have to make sure all the class files are in the same folder (duh)
Then you copy your java.exe from your jre folder into the folder with all your class files.
Finally, you create a shortcut to java.exe and add your class name to the command line on the shortcut.
Now all you have to do is double click on the shortcut and your program runs. Sure it's not that pretty but it works. -
Hey,
So I'd like to be able to execute another java program.
File directory = new File(".");
try {
List<String> l = new ArrayList<String>();
l.add("Java "+directory.getCanonicalPath+"AnotherProject/bin/main.class");
ProcessBuilder pb = new ProcessBuilder(l);
pb.start();
} catch (IOException ex) {
ex.printStackTrace();
}What am I doing wrong? I'm getting the error: "No such file or directory."
Edited by: Moopz on Nov 8, 2010 1:01 AMThat is entirely up to you! That will be your entry point. If you are able to think of you application as two parts one server, one client part and you have no problems building the separate parts into "working" applications, then their respective main methods would be good enough as start-methods. It's just a name.
Really, the principle is as easy as this, Suppose you have a HelloWorld class (think Server) and a GoodbyeMoon class (think client) looking like:
public class GoodbyeMoon {
public static void main(String[] args) {
System.out.println("Good bye, Moon!");
}Then you're application can do this:
public class LoginMain {
public static void main(String[] args) {
// ... GUI to select MOON or WORLD
if (userSelection == MOON ) {
GoodbyeMoon.main(null);
} else {
HelloWorld.main(null);
} -
How to execute a Java program from ODI
Hi All,
I am new to ODI. I would like to know whether its possible to execute a java program from ODI.
Reason for this is, I would like to write information in error tables into a file. And after that another program will mail that error log to concerned person.
Could anyone please help me with this?
Thank you in advance
Regards,
Sriniif you have the java code then u can create a procedure with Java BeanShell as the Technology and write your java code in the procedure
-
How can i run my java program with out java language
Hai to every one ..Iam new to java language ...am using windows xp operating system , i did not installed java language in my system .. how can i run a java program with out installing java language... Which files is requied to run java program..?
any one can help me??Hai to every one ..Iam new to java language ...am
using windows xp operating system , i did not
installed java language in my system .. how can i run
a java program with out installing java language...
you ... can ... not ... do ... this
Which files is requied to run java program..?
any one can help me??a JVM. Download it from sun's website.
[url http://java.sun.com/javase/downloads/index.jsp]Download JavaSE here -
How to run a standalone java program with JRC to display/run a report
Hi All,
I am new to this forum.
I am trying to run a java program developed using JRC to run a report created using Crystal Report XI. I stucked because not knowing how to run that java program.
Can anyone help me? or
can give a simple java code to do the same.
Thanks in advance.
Saravanakumar.Hi Saravana
For the steps to run a standalone application java program with JRC to display/run a report ,please refer the following link.
http://support.businessobjects.com/communityCS/TechnicalPapers/cr_xi_r2_jrc_deployment.pdf.asp
You can get the sample code for standalone/desktop applications from the following link.
http://support.businessobjects.com/communityCS/FilesAndUpdates/crxi_r2_jrc_desktop_samples.zip.asp
Please do revert in case of any queries.
Thanks
Soni -
Starting Java Program with a bash Shell script
Hi !
I know this is a Linux query but I am putting it on this site to get different answers.
I want to start my Java program with a shell script. Can anybody give me a proper script to start my Java program?
I am using RH Linux 7.3 and JDK 1.4.
Can I start the Java program without starting the terminal? Just like the Sun One Studio4 'runide.sh' script.
Please help.
Bye Niteenassuming you have your PATH and CLASSPATH variables set correctly, your script should look like this:
#!/bin/bash
cd <project_dir>
java <class> &
example:
#!/bin/bash
cd ~/projects
java project1.main_package.MainClass &
of course you could add some more elaborated stuff like compiling files before running the program, etc.
if you dont like terminals, try running "nautilus" (it's like Windows Explorer). i never use nautilus (especially for running scripts), so i cant guarantee it will work, although i dont see why it shouldnt... -
Interfacing a java program with hardware
I need to be able to interface a java program
with data in the parallel or serial ports of the computer.
I have no idea how to go about this, could someone please help me.
Thankshttp://java.sun.com/products/javacomm/
-
How to execute a DOS PROGRAM as batch file in java
How to execute a DOS PROGRAM as batch file in java
pls help mewww.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
-
How Can I execute a java program using java code?
{color:#000000}Hello,
i am in great trouble someone please help me. i want to execute java program through java code i have compiled the java class using Compiler API now i want to execute this Class file through java code please help me, thanks in advance
{color}Thanks Manko.
i think my question was not clear enough.. actually i want to run this class using some java code . like any IDE would do i am making a text editor for java, as my term project i have been able to complie the code usign compiler api and it genertaes the class file but now i want to run this class file "THROUGH JAVA CODE" instead of using Java command. I want to achive it programatically. do you have any idea about it.. thanks in advance -
Please help with executing a java program from another java program
Hi, I have tried to execute a very simple java program which is printed out "Hello world" from another java gui program when the user click on the "START" button. However, I don't receive any print out on the terminal when they click it. These two programs are being developed in Unix environment. Here is the code that I am trying to use.
Runtime r = Runtime.getRuntime();
r.exec("java HelloWorld");
p.s. HelloWorld is java class of the HelloWorld.javaI think you have to luanch your MS Prompt first before executing the command.
-
Execute an external java program with Runtime, problem with classpath
Hi,
I m calling an external java program by the command:
Runtime.getRuntime().exec("java -classpath \"library/*\" org.mypackage.TestMainProgram param1 c:/input/files c:/output/files");All my classes are stored in the relative directory "library", and it contains ONLY .jar files. However, I keep getting errors like:
"java.lang.NoClassDefFoundError: library/antlr/jarCaused by: java.lang.ClassNotFoundException: library.antlr.jar at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)Could not find the main class: library/antlr.jar. Program will exit.Exception in thread "main" where "antlr.jar" is a jar file in "library". It is there but still the program keeps complaining it cannot be found. The problem applies to any jars in "library", ie.., if i have "mylib.jar" then it will complain "NoClassDefFoundError: library/mylib/jar".
Could anyone give some pointers please?
Many thanks!
Edited by: 836590 on 14-Feb-2011 09:03836590 wrote:
Hi,
I m calling an external java program by the command:
Runtime.getRuntime().exec("java -classpath \"library/*\" org.mypackage.TestMainProgram param1 c:/input/files c:/output/files");All my classes are stored in the relative directory "library", and it contains ONLY .jar files. However, I keep getting errors like:
"java.lang.NoClassDefFoundError: library/antlr/jarCaused by: java.lang.ClassNotFoundException: library.antlr.jar at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)Could not find the main class: library/antlr.jar. Program will exit.Exception in thread "main" where "antlr.jar" is a jar file in "library". It is there but still the program keeps complaining it cannot be found. The problem applies to any jars in "library", ie.., if i have "mylib.jar" then it will complain "NoClassDefFoundError: library/mylib/jar".
Could anyone give some pointers please?
Many thanks!
Edited by: 836590 on 14-Feb-2011 09:03First, if you run from the command line
java -classpath "library/*" org.mypackage.TestMainProgram param1 c:/input/files c:/output/filesfrom the parent directory of library, does it work?
Despite what I said to Kayaman about Runtime.exec not expanding the asterisk, it looks like that's what's happening, so that you're getting
java -claspath library/aaaa_something_before_antlr.jar library/antlr.jar library/bbb.jar library/ccc.jar org.mypackage.TestMainProgram param1 c:/input/files c:/output/filesThat is, it *is* expanding the asterisk to a list of files in the directory, and the first one is being taken as the classpath, and the second one--library/antlr.jar is being taken as the class to execute. I'm certain this doesn't happen on Linux, so it must be a Windows thing.
Two suggestions:
1) Try single quotes instead of double.
2) Try the exec that takes an array
Runtime.getRuntime().exec(new String[] {"java", "-classpath", "'library/*'", "org.mypackage.TestMainProgram", "param1", "c:/input/files", "c:/output/files");Edited by: jverd on Feb 14, 2011 9:41 AM -
Using ProcessBuilder to execute multiple commands.
I am having issues getting ProcessBuilder to execute multiple commands in windows.
As an example I would like to execute "dir /w" fallowed by "java.exe some.App arg1 arg2".
I can accomplish this from the command line by using "&".
Example: dir /w & java.exe some.App arg1 arg2 Or: dir /w & dir /c"
For internal commands (i.e. dir and cd) I know that commands in the array being passed to ProcessBuilder must be formatted like {"dir /w", "dir /c"}
see post: [http://www.java-tips.org/java-se-tips/java.util/from-runtime.exec-to-processbuilder.html]
Here is an example of one of the many things I have tried:
{code}
String[] commands = new String[]{"dir /w", "&", "java.exe", "some.App", "arg1", "arg2"};
ProcessBuilder pb = new ProcessBuilder(commands);
pb.start();
{code}
Any other ideas / what am I doing wrong?
Edited by: brianjbrady on May 7, 2009 4:49 PM
Edited by: brianjbrady on May 7, 2009 4:50 PMbrianjbrady wrote:
You can run dir all day long without using cmd.exe. Try it. It works for me.Perhaps you have cygwin in your path.
How are you running dir out of interest (and don't say with a DOS window ;)
import java.io.*;
import java.util.Arrays;
public class Main {
public static void main(String... args) throws IOException {
run("dir");
run("dir.exe");
run("cmd", "/c", "dir");
run("c:\\cygwin\\bin\\dir");
private static void run(String... command) throws IOException {
try {
ProcessBuilder pb = new ProcessBuilder(command);
pb.redirectErrorStream(true);
Process p = pb.start();
InputStream is = p.getInputStream();
System.out.println("\nCommand " + Arrays.asList(command) + " reported");
int b;
while ((b = is.read()) >= 0)
System.out.write(b);
is.close();
p.destroy();
} catch (IOException e) {
System.err.println("\nCommand " + Arrays.asList(command) + " reported " + e);
}Prints
Command [dir] reported java.io.IOException: Cannot run program "dir": CreateProcess error=2, The system cannot find the file specified
Command [dir.exe] reported java.io.IOException: Cannot run program "dir.exe": CreateProcess error=2, The system cannot find the file specified
Command [cmd, /c, dir] reported
Volume in drive D is Work Disk
Volume Serial Number is AC0B-0757
Directory of D:\dev\scratch
26/12/2008 22:15 <DIR> .
26/12/2008 22:15 <DIR> ..
03/09/2007 21:45 <DIR> classes
26/08/2008 20:14 65,280 mynamedpipe
23/11/2008 11:37 201,354 name.ppt.txt
24/10/2008 20:00 201,354 race.txt
05/11/2008 23:17 6,193,334 record.csv
08/01/2009 16:44 704 scratch.iml
27/12/2008 12:29 21,576 scratch.ipr
08/05/2009 20:02 53,258 scratch.iws
28/04/2009 21:34 <DIR> src
07/12/2008 11:44 101 test.txt
8 File(s) 6,736,961 bytes
4 Dir(s) 32,506,023,936 bytes free
Command [c:\cygwin\bin\dir] reported
classes name.ppt.txt record.csv scratch.ipr src
mynamedpipe race.txt scratch.iml scratch.iws test.txt -
Error while executing HelloWorld.java program
Hi All,
I am trying to execute the samples(HelloWorld.java) program from Jdeveloper and provided the following details in runtime.defaults:
CONTENT_DB_URL
ADMIN_USER_NAME
ADMIN_USER_PASSWORD
however getting the following exception:
FdkException:
Error Code: ORACLE.FDK.UnexpectedError
Detailed Error Code: ORACLE.FDK.FeatureNotEnabled
Trace Id:
info (NamedValue[]): null
can any one please help me to resolve this issue.
Thanks
Krrish.See the Cleartext Authentication note in the running_client_samples.html file of the CDB devkit.
The default configuration for an out-of-box Oracle Content DB installation allows Cleartext Authentication only if SSL has been enabled (and the Web Services connection string begins with https). See the authentication topic for details.
To allow Cleartext Authentication to take place over standard (non-SSL) HTTP, set the Oracle Content DB domain property IFS.DOMAIN.WS.CleartextAuthenticationRequiresHttps to false using Enterprise Manager (Application Server Control). See the Content DB Administration Guide for details.
If the domain property above is not modified to false and Cleartext Authentication is attempted using using standard HTTP, an FdkException will be thrown:
ORACLE.FDK.UnexpectedError : ORACLE.FDK.FeatureNotEnabled
cheers
Matt.
Maybe you are looking for
-
MaxDB error while installing SAP Netweaver Developer Studio
Hello friends, I installed SNDS and later uninstalled but MaxDB is not removing from control panel - Add/Remove Software. then I used cleaner tool (walong with setup) to remove MaxDB but its still shows in control panel - Add/Remove Software. Now I a
-
16:9 video is rendered (shown) as 4:3
Hi, After upgrading to iTunes 9.0.3 I have videos that are supposed to be 16:9 being displayed as standard 4:3. Is it known issue, or it's something with my settings? Thanks, FTQuest
-
When adding security with 9.0 Pro Text in Document disappears!
I need to add no print/no edit security to a PDF. When I do this, the text of the entire document disappears after I save it. Why is this happening? Even when I close and open the document again, it opens as essentially a blank document. When I re
-
I can plainly see the photo in a folder I want to export but I get the message that Aperture cannot locate the master image...I have checked both external hard drives and that folder doesn't exist. Is there any way I can export or copy this one image
-
Hi, There is no proper app for App locker.. All other OS having Apps for app locker.. That only will help to prevent the messages and privacy from others. But for Windows there is no app locker softwares are available.. One of my frinds bought nokia