473,657 Members | 2,430 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Runtime process

I am trying to send a command to windows from my java program, and I get an
error.
The pertinent (?) part of my code follows:
public boolean action(Event evt, Object arg)
{ if (arg.equals("Ex ecute")){
inputText=(Stri ng)commandText. getText();
System.out.prin tln(inputText);
try{
Runtime rt = Runtime.getRunt ime();
//Process cp1=Runtime.get Runtime().exec( inputText);
//With the Runtime instance the program is run with the exec()
method:
Process process = rt.exec (inputText);
}
catch(IOExcepti on ee){
System.err.prin tln(ee+" can't run command");
System.exit(1);
}
}
else return super.action(ev t,arg);
return true;
}

I have written other java programs that successfully used this function, but
I don't know why this one doesn't work. Any suggestions?
Sep 29 '07 #1
2 3360
jerry chapman wrote:
>I am trying to send a command to windows from my java program, and I get an
error.
If that is a CodeIsDepressed Exception then the solution
is easy, we have drugs to treat that, in this day and age.

If it is something else, then you might progress the thread
by *stating* the exact exception, and perhaps even listing
a stacktrace that references the code lines that led to the
probem.
The pertinent (?) part of my code follows:
A good way to make sure the code includes the
pertinent lines is to prepare an SSCCE.
<http://www.physci.org/codes/sscce.html>
...
>I have written other java programs that successfully used this function, but
I don't know why this one doesn't work. Any suggestions?
Post an SSCCE with stacktrace.

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.asp...neral/200709/1

Sep 29 '07 #2
jerry chapman wrote:
public boolean action(Event evt, Object arg)
If I remember correctly, this would be the event dispatch model in Java
1.0 deprecated by Java 1.1?
I have written other java programs that successfully used this function, but
I don't know why this one doesn't work. Any suggestions?
1. Try using the more recent, non-deprecated version of the event model.
It's only been around for five versions of Java, after all.
2. After that, what exactly is the clue that it is not working? An error
message? No output? "It doesn't work" is very vague and is nearly
impossible to fix without more information.

--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth
Sep 29 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
9032
by: aa | last post by:
Anybody know the solution to trailing space in argument of Runtime.getRuntime().exec(arg), Process p = Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler C:\\Documents and Settings\\XX\\Desktop\\- Copy of TestingFolder -\\jjjj hihi.doc"); where there is 2 space between dash and "Copy of TestingFolder", but after going through Runtime.getRuntime().exec(arg), it chopes off one space and
4
24551
by: Hal Vaughan | last post by:
I never noticed this before, but when I run an external program through Runtime, like this: Runtime rt = Runtime.getRuntime(); System.out.println("Running external command: " + sCommand); try {Process p = rt.exec(sCommand);} catch (Exception e) {System.out.println("Cannot Run Command: " + sCommand + ", Error: " + e);} the external command is asynchronous -- completely spun off as a separate thread or process. Is there any way to...
1
5069
by: Hal Vaughan | last post by:
I've been using Runtime.exec() like this: Runtime rt = Runtime.getRuntime(); try {Process p = rt.exec("MyCommand.bat");} catch (Exception e) {do stuff} When I start my Java classes, I start them with a batch file that changes to my apps home directory. I've tried exec() with a full pathname (which seems to have problems on Windows if it has spaces in it, but I'm not sure if that's really the problem), with just the simple short batch...
2
11072
by: uwnewsgroup | last post by:
When I was using Runtime.exec(String cmd) to run a unix utility (join), and try to get its standard output by using Process.getOutputStream(), it blocks forever. I tried it using Java 1.4 and the results are the same on SunOS 5.8, Redhat8.0, cygwin. I read relevant articles and find the reason is that the output of the process exceeds the buffer allocated for that process. So can I adjust the buffer size (on any
8
9595
by: angelotti | last post by:
Hi everyone , i am banging my head over the following problem for a couple of weeks now: i am starting a MyProg.exe(a simple C app) from a java class with .exec() as a system process(not in it's own console) and i would like to communikcate with its I/O before it is finished. I don't have this issue if for instance i am starting another java app. The problem i meet is that the I/O is bloked while the process is being executed.When i terminate...
1
2849
by: ganeshp | last post by:
Hi , In my project i have come across a requirement where i must track the runtime of a process and terminate the process if it execeed a certain threshold limit. semthing like step 1: Create a child process step 2. Make child process perfrom some operation. Step 3: Make parent process monitor the runtime of the child process Step 4: Parent process to terminate the child process after threshold time say 1000000 seconds is equal...
7
8441
by: Norman Diamond | last post by:
A project depends on VC runtime from Visual Studio 2005 SP1, and DotNet Framework 2. Options are set in the setup project properties, so if these two dependencies are not already installed then this installer will install them. But what about the situation where VC runtime has already been installed? In fact it's been installed twice. Although the project was built on a Windows XP system with Visual Studio 2005 SP1 and the results were...
3
6989
by: Shayco | last post by:
hey, in my code i'm using Runtime.getRuntime().exec() in order to run a .bat file that calls another java program (they communicate with each other using RMI). when i call: Process process = Runtime.getRuntime().exec("cmd /c start C:\\MyFolder\\JavaApp.bat"); the seperate process runs perfectly, but when i add a space to the path: Process process = Runtime.getRuntime().exec("cmd /c start \"C:\\My Folder\\JavaApp.bat\""); then the java.exe...
1
3385
by: itxharsh | last post by:
/* While running the program a runtime error occurs."glibc detected" followed by a lot of memory address/instruction errors. Please help rectify this error.*/ /*Header file:"nonpreemptive.h" is as follows: #define C_OR_CPP 2 // Change value to 1 here if you are submitting a C solution for this problem. // Change value to 2 here if you are submitting a C++ solution for this problem. void dsmain();
0
8402
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8734
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8508
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8608
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7341
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6172
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4164
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1962
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.