Runtime.exec with spaces not working EVEN using String[]!!
Hi everyone,
I need to start the rmi registry from some code,and i need to pass it the classpath of two jars when initialising it. My problem is that the paths I set aren't taken when they contain a space.
Here's the code:
<code>
String rmiRegistryCommandLine[] = new String[] {
+ System.getProperty("java.home")
+ "\\bin\\rmiregistry.exe\"",
"-J-Djava.class.path=\""+System.getProperty("user.dir")+"\\MyJar.jar\"",
"1099"};
Runtime.getRuntime().exec(rmiRegistryCommandLine);
</code>
I know that Runtime.exec(String) tokenizes the input, which is why I'm not using it, but Runtime.exec(String[]) isn't supposed to tokenize the input. System.getProperty("user.dir") can contain a space, so I put quotes around that, but I need the -J-Djava.class.path in the same string. I tried breaking it up into two more separate strings but it didn't even run for normal non-space paths then. I am sure that if the whole -J-Dblah....upto MyJar.jar was in quotes then it would work, but I need the classpath in quotes separately as it could contain a space.
Can anyone help me get this working?
Ya, that's fine but the command line I want to pass is:
d:\j2sdk1.4.0\bin\rmiregistry.exe -J-Djava.class.path=d:\my dir with spaces\MyJar.jar;d:\my more dir with spaces\MyJar2.jar 1099
If I say
arg[0]="d:\\j2sdk1.4.0\\bin\rmiregistry.exe";, that's finebut arg[1] is the problem
if I say
arg[1]="-J-Djava.class.path=d:\\my dir with spaces\MyJar.jar; d:\\my more dir with spaces\\MyJar2.jar";, then it definitely won't work on 9X machines and probably not on NT.
if I break up arg[1] into:
arg[1]="-J-Djava.class.path=";
arg[2]="d:\\my dir with spaces\\MyJar.jar";
arg[3]=";";
arg[4]="d:\\my more dir with spaces\\MyJar2.jar";I'll need to put quotes around the two individual two class paths or else it won't work.
I find though that if I put the classpath as follows
d:\"my dir with spaces"\MyJar.jar then it seems to work.
I think a regular expression function to search for any directory with spacees and then put quotes around it and reinsert it into the path would be the solution.
Similar Messages
-
Runtime.exec() in Java not working in Oracle 10 Application Server
Hi ,
I am trying to call a .exe file which is in the Web Application folder .
I am Using Process p = Runtime.exec("path to .exe file ")
This code is working fine when used with JBOSS , but not working with Oracle Application server .
Please tell me whether i need to do any chnages to make it work
Thanks in advance .I ran a quick test with your code, I just had to make some small changes, and things work for me...
I'm testing with JDeveloper 10g 10.1.3.2.0 ...
The only thing I wonder is DBUser DBPass DBHost, those are not the actual values, correct?, neither they are environment variables?...
In the server hosting your OAS, you should try running the whole CMD line from the start/run dialog ... make sure it works in that server ...
Here is the code used in my test:
In JSP:
<%@ page import="runexepkg.*" %>
<%
String msg = "";
try
RunEXE p = new RunEXE();
msg = p.main1();
catch(Throwable t)
System.out.println("Exception Raised");
t.printStackTrace();
%>
<%= msg %>In Java Class:
package runexepkg;
import java.sql.*;
public class RunEXE
String ss="";
public String main1()
try
Runtime rt=Runtime.getRuntime();
Process p = rt.exec("CMD /C start C:\\oraappserver\\j2ee\\WebGis\\applications\\PowerGis\\web\\WEB-INF\\classes\\GisProject\\cust_data_1.exe DBUser DBPass DBHost");
System.out.println("Command has been executed");
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@DBHost:DBPort:orcl","DBUser","DBPass");
System.out.println("Test Connection ========== "+con);
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("SELECT SYSDATE FROM DUAL");
if(rs.next())
ss="Command has been executed - Database has been accessed";
else
ss="Command has been executed - Database was not accessed";
catch(Throwable t)
System.out.println("Exception raised, command has NOT been executed");
ss="Exception raised, command has NOT been executed";
t.printStackTrace();
return ss;
}Edited by: Rodolfo Ferrari on Jul 23, 2009 10:40 PM -
DONT UPDATE TO MAVERICK IT CREATES PROBLEMS
can anybody at apple sort out as the help i have had since i updateed to maverick is a waste of my time
I CANT USE FINDER OR ANY APPLICATIONS TO DO WITH IT SINCE UPGRADING TO MAVERICK AND
I DONT THINK EVEN APPLE CAN SORT IT WHAT A PAIN BRING BACK SNOWLION PLEASE I WISH I DIDNT EVEN UPDATE NOWHey briannagrace96,
Welcome to Apple Support Communities! I'd check out the following article, it looks like it applies to your situation:
iPod: Appears in Windows but not in iTunes
http://support.apple.com/kb/ts1363
You'll want to go through the following troubleshooting steps, and for more detail on each step follow the link to the article above:
Try the iPod troubleshooting assistant:
If you have not already done so, try the steps in the iPod Troubleshooting Assistant (choose your iPod model from the list).
If the issue remains after following your iPod's troubleshooting assistant, follow the steps below to continue troubleshooting your issue.
Restart the iPod Service
Restart the Apple Mobile Device Service
Empty your Temp directory and restart
Verify that the Apple Mobile Device USB Driver is installed
Change your iPod's drive letter
Remove and reinstall iTunes
Disable conflicting System Services and Startup Items
Update, Reconfigure, Disable, or Remove Security Software
Deleting damaged or incorrect registry keys
Take care,
David -
Change Password with spaces not working
Hi,
I have configured password policy in OIM as Minimum length as 8
Min Numeric characters 6
Min Uppercase Characters 1
Special Character Minimum 1
Disallow last passwords 12
Now at the time of changing password it is accepting spaces in password and when we trying to log in with that password [password having spaces] it is not accepting and we are not able to log in with taht user
Please reply soon.
ThanksAny updates??
-
The Runtime.exec methods doesn't work well on Solaris ???
I have two threads and I set the different running time.
I use Runtime.exec to a run the command and use Process to get the process.
It works properly in the windows2000 platform.
However, when I transfer the platform to Solaris...and run the program...
Two threads always at the same time....It is very wired....I always debug
for 2 days....
(at first I run "vmstat 1 2" command, later I change to "ls","rmdir"....etc,
all of them don't work.....
If I close the Runtime.exec..........Everything works well......)
And I study the API. I found this message...
The Runtime.exec methods may not work well for special processes on certain
native platforms, such as native windowing processes, daemon processes,
Win16/DOS processes on Win32, or shell scripts. The created subprocess does
not have its own terminal or console.
Could someone share her/his experience.....:(
And if any other way I can run command inside java code instead of
Runtime.exec.....???
Please reply my mail to [email protected] I do appreciate your kindly &
great help!!!!!!!!
This is my code.......
import java.io.*;
import java.lang.*;
import java.util.*;
* <p>ServerThread1</p>
* <p>??�X???��?�D???�X???, "Vmstat 1 2".</p>
class ServerThread1 extends Thread{
private ServerAgent Sa;
public ServerThread1 (String Name, ServerAgent Sa){
super(Name);
this.Sa = Sa; file://Assign ServerAgent reference Sa
public void run(){
while(true){
try{
Thread.sleep(5000);
catch (Exception e){
System.out.println("ServerThread1 fails");
System.out.println("Thread1 is running.");
try {
Runtime rt1 = Runtime.getRuntime();
Process proc1 = rt1.exec("mkdir"); ------>If I close
rt1.exec , two threads works seperately...........:(
catch (Exception e) {
System.out.println("Thread1 Error");
class ServerThread2 extends Thread{
private ServerAgent Sa;
public ServerThread2 (String Name, ServerAgent Sa){
super(Name);
this.Sa = Sa;
public void run(){
while(true){
try{
Thread.sleep(15000);
catch (Exception e){
System.out.println("ServerThread2 fails");
System.out.println("Thread2 is running.");
try {
Runtime rt2 = Runtime.getRuntime();
Process proc2 = rt2.exec("vmstat 1 2"); ----->If I don't run
the rt2.exe, two threads work seperately....
catch (Exception e) {
System.out.println("Thread2 Error");
public class ServerAgent{
private Vector v1 = new Vector();
private Vector v2 = new Vector();
private Hashtable currentData = new Hashtable();
private static String startUpSwap = null;
private static String startUpMem = null;
public static void main(String[] arg) {
ServerAgent s = new ServerAgent();
ServerThread1 st1 = new ServerThread1("Thread1",s);
ServerThread2 st2 = new ServerThread2("Thread2",s);
st1.start();
st2.start();If I close the Runtime.exec..........Everything works
well......)You don't empty the output of the command, that blocks the process.
A citation from
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
Why Runtime.exec() hangs
The JDK's Javadoc documentation provides the answer to this question:
Because some native platforms only provide limited buffer size for standard input and output streams, failure to promptly write the input stream or read the output stream of the subprocess may cause the subprocess to block, and even deadlock.
Try out something like this:
String s;
try {
Process myProcess =
Runtime.getRuntime().exec("ls -l"));
DataInputStream in = new DataInputStream(
new BufferedInputStream(myProcess.getInputStream()));
while ((s = in.readLine()) != null) {
out.println(s);
catch (IOException e) {
out.println("Error: " + e);
}Another source of trouble under Unix is not having the correct permission for that user that executes the Java VM, which will be the permissions for the spawned subprocess. But this probably not the case, as you see something after exit.
Regards,
Marc -
Why does my iMessage not work even with my apple ID signed in?
Why does my iMessage not work even with my apple ID signed in?
Using FaceTime http://support.apple.com/kb/ht4319
Troubleshooting FaceTime http://support.apple.com/kb/TS3367
The Complete Guide to FaceTime + iMessage: Setup, Use, and Troubleshooting
http://tinyurl.com/a7odey8
Troubleshooting FaceTime and iMessage activation
http://support.apple.com/kb/TS4268
iOS: FaceTime is 'Unable to verify email because it is in use'
http://support.apple.com/kb/TS3510
Using FaceTime and iMessage behind a firewall
http://support.apple.com/kb/HT4245
iOS: About Messages
http://support.apple.com/kb/HT3529
Set up iMessage
http://www.apple.com/ca/ios/messages/
iOS 6 and OS X Mountain Lion: Link your phone number and Apple ID for use with FaceTime and iMessage
http://support.apple.com/kb/HT5538
How to Set Up & Use iMessage on iPhone, iPad, & iPod touch with iOS
http://osxdaily.com/2011/10/18/set-up-imessage-on-iphone-ipad-ipod-touch-with-io s-5/
Troubleshooting Messages
http://support.apple.com/kb/TS2755
Troubleshooting iMessage Issues: Some Useful Tips You Should Try
http://www.igeeksblog.com/troubleshooting-imessage-issues/
Setting Up Multiple iOS Devices for iMessage and Facetime
http://macmost.com/setting-up-multiple-ios-devices-for-messages-and-facetime.htm l
FaceTime and iMessage not accepting Apple ID password
http://www.ilounge.com/index.php/articles/comments/facetime-and-imessage-not-acc epting-apple-id-password/
FaceTime, Game Center, Messages: Troubleshooting sign in issues
http://support.apple.com/kb/TS3970
Unable to use FaceTime and iMessage with my apple ID
https://discussions.apple.com/thread/4649373?tstart=90
How to Block Someone on FaceTime
http://www.ehow.com/how_10033185_block-someone-facetime.html
My Facetime Doesn't Ring
https://discussions.apple.com/message/19087457
Send an iMessage as a Text Message Instead with a Quick Tap & Hold
http://osxdaily.com/2012/11/18/send-imessage-as-text-message/
To send messages to non-Apple devices, check out the TextFree app https://itunes.apple.com/us/app/text-free-textfree-sms-real/id399355755?mt=8
How to Send SMS from iPad
http://www.iskysoft.com/apple-ipad/send-sms-from-ipad.html
You can check the status of the FaceTime/iMessage servers at this link.
http://www.apple.com/support/systemstatus/
Cheers, Tom
BTW- Your profile shows you have iOS 6.1.4 installed. The max iOS for an iPad is 6.1.3. iOS 6.1.4 is for iPhones only. -
Revision: 4193
Author: [email protected]
Date: 2008-11-26 11:40:05 -0800 (Wed, 26 Nov 2008)
Log Message:
Bug: LCDS-517 - Reliable messaging destinations created using runtime configuration (bootstrap service) not working.
QA: Yes
Doc: No
Checkintests Pass: Yes
Details:
* Foundational update to include destination config in what we collect for runtime config exchange with new clients for destinations with network/reliable=true (LCDS only).
* Also typo in comment in AbstractConnectionAwareSession fixed.
Ticket Links:
http://bugs.adobe.com/jira/browse/LCDS-517
Modified Paths:
blazeds/trunk/modules/core/src/flex/messaging/AbstractConnectionAwareSession.java
blazeds/trunk/modules/core/src/flex/messaging/Destination.java
blazeds/trunk/modules/core/src/flex/messaging/services/AbstractService.javaRevision: 4193
Author: [email protected]
Date: 2008-11-26 11:40:05 -0800 (Wed, 26 Nov 2008)
Log Message:
Bug: LCDS-517 - Reliable messaging destinations created using runtime configuration (bootstrap service) not working.
QA: Yes
Doc: No
Checkintests Pass: Yes
Details:
* Foundational update to include destination config in what we collect for runtime config exchange with new clients for destinations with network/reliable=true (LCDS only).
* Also typo in comment in AbstractConnectionAwareSession fixed.
Ticket Links:
http://bugs.adobe.com/jira/browse/LCDS-517
Modified Paths:
blazeds/trunk/modules/core/src/flex/messaging/AbstractConnectionAwareSession.java
blazeds/trunk/modules/core/src/flex/messaging/Destination.java
blazeds/trunk/modules/core/src/flex/messaging/services/AbstractService.java -
The g, h and backspace on my keyboard are not working even after replacing with a new one. I have also updated my BIOS still d same. Please help me ASAP.
...am waiting for a QIUCK RESPONSEHow does a usb keyboard attached externally work?
You might try a "hard reset" where you remove battery and AC charger, hold down power button 20-30 seconds and then reassemble and turn on. Reset BIOS (F10) to default settings, too. -
Revision: 4226<br />Author: [email protected]<br />Date: 2008-12-03 15:25:17 -0800 (Wed, 03 Dec 2008)<br /><br />Log Message:<br />-----------<br />Bug: LCDS-517 - Reliable messaging destinations created using runtime configuration (bootstrap service) not working. <br />QA: Yes<br />Doc: No<br />Checkintests Pass: Yes<br /><br />Details:<br />* Make sure the <reliable/> option is treated as a nested element rather than an attribute of its parent <network> element.<br /><br />Ticket Links:<br />------------<br /> http://bugs.adobe.com/jira/browse/LCDS-517<br /><br />Modified Paths:<br />--------------<br /> blazeds/trunk/modules/core/src/flex/messaging/Destination.java
Revision: 4226<br />Author: [email protected]<br />Date: 2008-12-03 15:25:17 -0800 (Wed, 03 Dec 2008)<br /><br />Log Message:<br />-----------<br />Bug: LCDS-517 - Reliable messaging destinations created using runtime configuration (bootstrap service) not working. <br />QA: Yes<br />Doc: No<br />Checkintests Pass: Yes<br /><br />Details:<br />* Make sure the <reliable/> option is treated as a nested element rather than an attribute of its parent <network> element.<br /><br />Ticket Links:<br />------------<br /> http://bugs.adobe.com/jira/browse/LCDS-517<br /><br />Modified Paths:<br />--------------<br /> blazeds/trunk/modules/core/src/flex/messaging/Destination.java
-
Revision: 4195
Author: [email protected]
Date: 2008-11-26 13:08:23 -0800 (Wed, 26 Nov 2008)
Log Message:
Bug: LCDS-517 - Reliable messaging destinations created using runtime configuration (bootstrap service) not working.
QA: Yes
Doc: No
Checkintests Pass: Yes
Ticket Links:
http://bugs.adobe.com/jira/browse/LCDS-517
Modified Paths:
flex/sdk/trunk/frameworks/projects/rpc/src/mx/messaging/config/ServerConfig.asRevision: 4195
Author: [email protected]
Date: 2008-11-26 13:08:23 -0800 (Wed, 26 Nov 2008)
Log Message:
Bug: LCDS-517 - Reliable messaging destinations created using runtime configuration (bootstrap service) not working.
QA: Yes
Doc: No
Checkintests Pass: Yes
Ticket Links:
http://bugs.adobe.com/jira/browse/LCDS-517
Modified Paths:
flex/sdk/trunk/frameworks/projects/rpc/src/mx/messaging/config/ServerConfig.as -
I`veupdating my iphone to version 6 but the buttons of sound not working even more the soundsof all app was lost
any body have an idea about my problem?
-
Iphone 4 front camera not working even after reboot,resets and restore.
i am using iphone 4 .I have problem that front camera is not working even after reboot,resets and restore with itunes.I thing there is a hardware problem.
Now i wont to go apple store for replace the phone because phone is under warranty period.But problem is that i lost the receipt.Will apple store help me without my receipt ?please help meIf setting up as new device without using the latest backup does not bring the camera function back, get it looked at or serviced by Apple:
How to back up your data and set up as a new device
Apple - Support - Service Answer Center -
Runtime.exec() with .bat-files in a jar
Hi All,
I've written a java-Program, which calls .bat-files per Runtime.exec() for some OS-specific tasks.
Everything works fine, but if I want to pack the whole code and the .bat-files into several jars, I can't get the bat-files to run. I have tried to get it to work with "getClass().getResource()" as I do the same for my Images, and the returned URL seems to be OK so far (something like jar:file:/c:/test.jar! testpkg/test.bat). I converted this URL into a String and tried to run Runtime.exec() with it, but I always get a Runtime-Exception.
The String looks exactly like the URL, when I print them to console.
These bat-files are essential for the application and I would not try to pack them into a jar if I hadn't to distribute this application as a signed applet to unknown users, too.
I hope there is anyone out there who can tell me if and how it is possible to run an external program out of java, which is packed into a jar, so thanx in advance to any helpful replies.
acdekaYou can't run the .bats simply because the shell can't access it. You tell it to run a file that simply doesn't exist in the OS.
-
I have checked the box "display date and time on the Menu Bar" and it does not work. Using OS X Yosemite 10.10.2 Anybody have a fix?
Please read this whole message before doing anything.
This procedure is a test, not a solution. Don’t be disappointed when you find that nothing has changed after you complete it.
Step 1
The purpose of this step is to determine whether the problem is localized to your user account.
Enable guest logins* and log in as Guest. Don't use the Safari-only “Guest User” login created by “Find My Mac.”
While logged in as Guest, you won’t have access to any of your documents or settings. Applications will behave as if you were running them for the first time. Don’t be alarmed by this behavior; it’s normal. If you need any passwords or other personal data in order to complete the test, memorize, print, or write them down before you begin.
Test while logged in as Guest. Same problem?
After testing, log out of the guest account and, in your own account, disable it if you wish. Any files you created in the guest account will be deleted automatically when you log out of it.
*Note: If you’ve activated “Find My Mac” or FileVault, then you can’t enable the Guest account. The “Guest User” login created by “Find My Mac” is not the same. Create a new account in which to test, and delete it, including its home folder, after testing.
Step 2
The purpose of this step is to determine whether the problem is caused by third-party system modifications that load automatically at startup or login, by a peripheral device, by a font conflict, or by corruption of the file system or of certain system caches.
Please take this step regardless of the results of Step 1.
Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards, if applicable. Start up in safe mode and log in to the account with the problem. You must hold down the shift key twice: once when you turn on the computer, and again when you log in.
Note: If FileVault is enabled in OS X 10.9 or earlier, or if a firmware password is set, or if the startup volume is a software RAID, you can’t do this. Ask for further instructions.
Safe mode is much slower to start up and run than normal, with limited graphics performance, and some things won’t work at all, including sound output and Wi-Fi on certain models. The next normal startup may also be somewhat slow.
The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
Test while in safe mode. Same problem?
After testing, restart as usual (not in safe mode) and verify that you still have the problem. Post the results of Steps 1 and 2. -
Error Parser does not work, even in SSX3
SunSudio Express (December 2006 release) introduces some interesting new features, but there are still problems. For the first time, I was able to debug Fortran 90 applications in Linux, but debugging is still very limited. Furthermore, the Fortran error parser does not work, even when compiling using Sun's f95 compiler. This is a heavy disadvantage. I assume that Fortran error parsing is not supported on Linux, although the tutorials don't make this point clear: In the Options window, there are settings concerning C/C++ (and its parser), but there are no similar options for the Fortran parser, even in "Advanced Setings" (which are similar to the old Options window). My Linux system is Debian 3.1 (Sarge), with JDK 1.5.0.09.
I don't think that I'm doing something wrong, but I want to ask, just to be sure: has someone had seen the Fortran error parser working on Linux? What about Fortran word completion?SunSudio Express (December 2006 release) introduces some
interesting new features, but there are still problems. For the first time,
I was able to debug Fortran 90 applications in Linux, but debugging is
still very limited. This is good to know that you were able to debug a f90 application
on Linux. What problems do you see? Please, report them, and we
will file them as bugs or RFEs (requests for enhancements).
Furthermore, the Fortran error parser does not work, even when
compiling using Sun's f95 compiler. Yes, you are right, this feature does not work yet.
This is a heavy disadvantage. I assume that Fortran error parsing
is not supported on Linux, although the tutorials don't make this
point clear: Yes, it does not work yet on all platforms.
In the Options window, there are settings concerning C/C++ (and
its parser), but there are no similar options for the Fortran parser,
even in "Advanced Settings" (which are similar to the old Options
window). There will be similar options for Fortran.
My Linux system is Debian 3.1 (Sarge), with JDK 1.5.0.09.JDK 1.5.0.09 is ok.
We do not target Debian system, but we assume everything
should work there (we test on Red Hat and SUSE).
Good to know that our assumption is correct :-)
I don't think that I'm doing something wrong, but I want to ask, just
to be sure: has someone had seen the Fortran error parser working
on Linux? No. It does not work on Linux, and it does not work on other platforms.
What about Fortran word completion? No, this feature is not implemented yet.
Thanks you for trying Sun Studio 12 Express release and for your report.
Nik
Maybe you are looking for
-
I'm using Sountrack 1.5. The menu choices: Search, Favorites, Bin, Effects (under the Windows menu) are all greyed out. I have on my hard drive all the support files. (in the Library folder, Audio, etc) I have no idea why these are grey. I can't star
-
Balancing field "Profit Center" in line item not filled - Error during GR
Hi When we tried to do MIGO for a non stock material (Account assignment category K), we are getting an error message that "Balancing field "Profit Center" in line item 001 not filled". The interesting factor is that we did the GR for similar kind o
-
This is a spin off from a previous issue I had but now I think this is a bug and it appears to only be in the Post.aspx view. To summarize, when the exact same web part is added to the POST.aspx page as well as the /Forms/AllItems.aspx page, it crash
-
Can i view customer report as per the business area wise , region-wise how?
can i view customer report as per the business area wise , region-wise how?
-
Logs vary in sm20 and RSAU_SELECT_EVENTS
Hi, Logs which appear in sm20 do not appear in RSAU_SELECT_EVENTS. why is this happeneing? Regards Divya