Question about class Runtime

Hi
Do you know why Runtime would not exec()
following strings when called from a servlet
"source lst" - gives error 500
"ls > lst" - No error, but does nothing
no file lst created...
Thanks
Dmitriy

See http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

Similar Messages

  • Question about using Runtime.getRuntime();

    hi all
    i have a question about using Runtime.getRuntime(). if i use this to get a runtime reference to run an external program, is it considered as starting a new thread inside the thread that starts it?
    is it safe to do it in the Session EJB? if not, what can you recommand to do it? thanks

    hi all
    i have a question about using Runtime.getRuntime().
    if i use this to get a runtime reference to run an
    external program, is it considered as starting a new
    thread inside the thread that starts it? No. Starting a process, starts a process. Threads have nothing to do with it.
    is it safe to do it in the Session EJB? if not, what
    can you recommand to do it? thanksSo what? Run another process? If you want to run another process in java then your choices are to use Runtime.exec() or use JNI. And using JNI will probably end up doing exactly the same thing as Runtime.exec().
    "Safe" is harder. Typically to correctly use Runtime.exec() you must use threads. And as noted threads ideally should not be used. You can use them but if you do you had better understand why they didn't want you using them in the first place. You had also better be sure that you really want to wait for it to complete.
    Other than that Runtime.exec() is safe because it can't crash the VM like other interfaces can (like JNI.)

  • Questions about classes

    Hi,
    I finally upgraded from Flash 5 to CS3 - big difference :-)
    Reading the first half of an ActionScript 3 book left me
    quite confused about classes - what they are, how you handle
    multiple classes, how you use one class from within another etc.
    Are there any simple-speak tutorials out there that explain
    more about how to use classes?
    Specifically:
    I am trying to use classes to run multiple animations at the
    same time, i.e. using randomized movement for multiple objects on
    my stage.
    First issue is: If I do what I learnt in the book and simply
    create one .as file and have that be the document class, how can I
    prevent it from being run before all the elements on the stage have
    been loaded through a slow network connection?
    Second issue: I'd rather have "dormant" classes sitting
    around and call them once my stage is ready, but I have no idea how
    to handle multiple classes. I played with it for a while and then
    gave up and put my code into a frame, but that caused further
    issues. Again, any tutorials out there or any other advice you can
    give me? I am trying to start some class code at a certain time and
    use it to attach a Frame Event listener to a Sprite that I create
    inside the class.
    It looks easy in the book, but when I try to do my own stuff,
    it just won't do it...
    The book assumes (so far) that you want to run your code
    immediately once your movie starts, but I don't want that...
    Thanks!

    Yes, I realized later that _root etc. is actually as1 code
    from my days of Flash 5 :-)
    All I need is to know how to access a movieclip on the stage
    that was placed using the IDE from within a class, and how to
    access a class and call its methods from within another, and I can
    teach myself the rest...
    So, if I place something with the IDE, doesn't it show up in
    the display list? I should be able to control those elements, too,
    shouldn't I?
    Or do I have to use Actions rather than classes for those
    elements?
    I probably read 5 different articles/ebooks on the topic of
    classes and OOP in AS3 already, and none gave me the answer I
    needed.
    But I will have a look at the site you mentioned.
    Thanks!

  • Question about Classes

    I have a question concerning classes. In my main program I have a list box. I have gotten the index (using getSelectedIdex method) from the list box to use with my array. What I want to do is match the list box index with the array index to get the correct price from the array. I can do this in the main class, but was wondering if I could just do the calculations in another class. Can I pass the index of the list box to another class in order to do the calculations? I figure I could put the array in the other class too and match them. In order to do this, what would the class data member look like for the list box index that I have passed? I have tried and get errors, so was wondering if there was another way I can do this
    Thanks so much for your help

    I have a question concerning classes. In my main
    program I have a list box. I have gotten the index
    (using getSelectedIdex method) from the list box to
    use with my array. What I want to do is match the list
    box index with the array index to get the correct
    price from the array. I can do this in the main
    class, but was wondering if I could just do the
    calculations in another class. Yes you can, but why? The only reason to do this from a design point of view would be to seperate the logic into another class so that;-
    1. you might reuse the class in the future.
    2. the main method class has become large and cumbersome making it difficult to find all the methods.
    3. There are a variety of methods and subroutines in your application so that the logic in your program will be improved in terms of readability and future maintenance by creating seperate class files.
    4. 'whatever' other reasons (?)
    Can I pass the index of
    the list box to another class in order to do the
    calculations? I figure I could put the array in the
    other class too and match them. In order to do this,
    what would the class data member look like for the
    list box index that I have passed? I have tried and
    get errors, so was wondering if there was another way
    I can do this
    Sooner or later the would-be java programmer has to change or make the transition from using java as a procedural language and develop programs along more OOP lines. The answer to your question is "yes of course you can do this" and simply from the point of view of learning how to pass an argument to a different class, then yeah, learn how to do this.
    >
    Thanks so much for your help
    Gazoontite xxx

  • Question about classes/Directories

    I've been using Java to learn programming for a while now, so this question may not belong here. It seems to be more of a general question, however, not code related.
    How does java work with directories? Say I had a project, and for some reason I wanted different java class files to be in different directories. How does java handle this? Say for example:
    1.) Main class is in C:/blahblah/Project/ and the other classes were in C:/blahblah/Project/src/?
    2.) Main class is in C:/blahblah/Project/src/ and the other classes were in C:/blahblah/Project/?
    3.) Main class is in C:/blahblah/Project/src/ and other classes were in C:/blahblah/Project/bin/?
    I know these may be kind of stupid examples, but I just wanted to know how such things worked for future reference. Thanks a ton!

    {color:#3D2B1F}It sounds like you need to learn about packages: [http://java.sun.com/docs/books/tutorial/java/package/index.html] {color}

  • MenuStrip and a Question about Class win32_product

    Hello,
    I have a bunch of questions I'm hoping someone can answer.
    1.) I would like to add a menu separator and a checkbox under a dropdownitem for a toolstripmenuitem
         Similar to what you would see in ISE or Internet Explorer.
         I then need to pass the state of this checkbox into a function
    2.) I have created a file menu item and would like to create a separator and then add a list of MRU items restricted to only displaying the five previous opened config files.
    3.) Can someone propose an alternative to using the get-wmiobject win32_Product class
    The below function I wrote to get the Product Version for some VMware products, but it is slow making the initial connection.   Looking at the Uninstall registry key won't work because it doesn't contain the product version.
    I know it looks odd.  I could not find a good way to detect which servers the products were installed on.   So instead I pass the servers that would host these products based on our build standards.
    Function get-version($vcenter,$sso,$vum,$credentials) {
    Write-Host "Getting Version information. This usually takes awhile. Be Patient " -NoNewline
    $Roles = "VMware vCenter Server","VMware vCenter Inventory Service","VMware vSphere Web Client","vCenter Single Sign On","VMware vSphere Update Manager","vSphere Syslog Collector"
    $i = 0
    $output = @()
    $Servers = "$vcenter","$vcenter","$vcenter","$sso","$vum","$vum"
    $ErrorActionPreference = 'silentlycontinue'
    ForEach ($input in $Servers) {
    IF ($psversiontable.psversion.major -ge 3) { Write-Progress -activity "Getting Version Information - Takes awhile. Be Patient." -status $Roles[$i] -PercentComplete (($i / $roles.Length) * 100) } Else { ticker }
    $object = New-Object PSObject
    $object | Add-Member NoteProperty "Role" $Roles[$i]
    $object | Add-Member NoteProperty "Hostname" $Servers[$i]
    $object | Add-Member NoteProperty "IP Address" (Get-WmiObject Win32_networkadapterconfiguration -ComputerName $Servers[$i] -Credential $credentials | ? {$_.IPEnabled} | Select-Object IPaddress).IPaddress[0]
    $object | Add-Member NoteProperty "Version" (Get-WmiObject win32_Product -ComputerName $Servers[$i] -Credential $credentials | Where-Object {$_.Name -eq $Roles[$i]}).version
    $output += $object
    $i++
    IF ($PSVersionTable.PSVersion.Major -ge 3) { Write-Progress -activity "Completed Getting Version Information" -Completed } Else { write-host "...Done!" -NoNewline }
    write-host ""
    $output
    } # End Function get-Version
    Walter

    Your code doesn't relay make much sense.
    What is this line for:
    $Servers = "$vcenter","$vcenter","$vcenter","$sso","$vum","$vum"
    Funtion get-version($vcenter,$sso,$vum,$credentials
    Why are you using credentials.  Only and admin can call remotely?
    Are you trying to get all of these roles? Aren't these produces?
    $Roles  = "VMware vCenter Server","VMware vCenter Inventory Service","VMware vSphere Web Client","vCenter Single Sign On","VMware
    vSphere Update Manager","vSphere Syslog Collector"
    ¯\_(ツ)_/¯

  • A question about class and interface? please help me!

    the following is program:
    interface A{
    public class B implements A{
    public static void main(String [] args){
    A a = new B();
    System.out.println(a.toString());
    }i want to ask a question, the method toString() is not belong to interface A, why a can call method toString()? the interface call the method that isn't belong to, why? please help me...

    because a.toString() call the method toString() of class Object because B implements A, but extends Object and in the class Object there is a method toString(). infact if you override the method toString() in class B, a.toString() call toString() in class B.
    try this:
    interface A {}
    public class B implements A
      public String toString()
        return "B";
      public static void main(String [] args)
        A a = new B();
        System.out.println(a.toString());
      }by gino

  • General question about classes

    Hi every one,
    I have an application that works but i'll like to optimize it, regarding about speed and system ressources. For resume and represent diagrammatically the application I wrote, there is a first frame (the main menu) with severals buttons. When I push a button I show a new frame with a query resultset displayed inside.
    Theses second frames are all very similars, just a few things are differents between one and another (sql string of the query, and some controls may be visible or not).
    So there are many solutions to write it :
    1- I can make a class representing this second frame and each time I push a button from the main menu, I create a new Object with this class and when I quit this frame I do a "dispose" of it.
    2 - (the solution I got) I create an Object with the model of this second frame once and for all, and when I push a button I set visible this frame and call a method to change some parameters, when I quit the frame I set it hide.
    I think second option is not to bad and the first one is very heavy, but If I created a class B that extends my second frame A (that contains the main code for displaying results) and each time I push a button from the main menu I created an object from B type, is it a good idea ??
    Hope you understand my problem, and hope anyone will give me an idea...

    Hi rainek and ty for your attention,
    Yes you understood right :
    my app creates Frame 1 with buttons and show it, and I create on the background a raw version of Frame 2 shown, and with changed parameters when button is pressed.
    But I don't not extend Frame 2 with a SubFrame 2, I just wonder if it would be a good thing to create subframe 2 and instance it each time I push a button from Frame 1, instead to use the same Frame 2 raw version (storing it in a file config indeed) from the background. I wondered, if when I instance for the second time a subframe 2 it was speeder because an object subframe 2 as already been instancied before.
    You know my problem was also that when I created Frame 2 in the background before create Frame 1, it gave my troubles with Frame 1 display (cf. my topic :http://forums.java.sun.com/thread.jsp?forum=57&thread=231897), so now I create this frame 2 raw version the first time I push any button, but of course there is a litte big longer time answer this first time. (I thank too, to create Frame 2 raw version in a thread to avoid frame 1 display troubles)
    Hope I'm clear and you understand me, for resume in a generic problem, I wonder know if when i have this config :
    Frame 2,
    Subframe2 that extends Frame 2
    if i do
    Subframe2 myframe_a = new Subframe2 (<parameters_a>) and
    Subframe2 myframe_b = new Subframe2 (<parameters_b>)
    myframe_b is created more quickly because myframe_a as been instancied before
    Any way ty very much for your answer rainek !!

  • A question about classes

    Hi all,
    This is a general question, hope it is in the right forum.
    Lets say I have a main document class, declared in the property window. I can easily create new instances of a movieclip in my library by simply creating them in my document class and then using addchild to put them on the stage. Now lets say I have a separate external class that I am importing into my document class. How do I create instances of the movieclip from my library in that external class. All I want my document class to do is import classes and let them do the work so to speak. I know I can create the movieclip instance in the document class and pass it as a parameter when I import the external class but what if I want to create it there?
    I hope that makes sense, I am sure it is very simple but I am tired of having massive long document classes!
    Thanks in advance.

    Hi, sorry I know you answered this but I have just done a quick test file to try the instantiation,
    the movieclip is not showing, the movieclip is linked out with a class of mcSquare.
    //document class
    package {
        import flash.display.MovieClip;
        import external;
        public class document extends MovieClip
            public var externalClass:external = new external();
            public function document()
    //external
    package {
        import flash.display.*;
        import flash.utils.getDefinitionByName;
        public class external extends MovieClip
            public var square_mc1:mcSquare = new mcSquare();
            /*public var square:Class = getDefinitionByName("mcSquare") as Class;
            public var square_mc1:Object = new square();*/
            public function external()
                //square_mc1.x = 43.5;
                //addChild(DisplayObject(square_mc1));
                addChild(square_mc1);
    The commented code is just attempts after googling.
    Again apologies for reposting, I thought that had cracked it
    Thanks

  • Question about classes hyargie

    hello, my english is very bad so, but i think you can understand my problem:
    i'm creating a game, in Java using jEdit and have 3 classes: one application with the static main, called Memory. That one creates another one, called Game. It's a canvas. Till here no problem.
    But when I try to create from the the class Game a class Kaart, he'll give an error:
    the code looks like this
    public class Game extends Canvas
    private Kaart kaartje;
         public Game( int dinges )
    kaartje = new Kaart( 27, 16 );
    add( Kaartje ); //<---------------------
    this is the error:
    C:\Jan\proggen\Game.java:34: add(java.awt.PopupMenu) in java.awt.Component cannot be applied to (Kaart)
              add( kaartje );
    ^
    1 error
    anyone know about this..?
    thanks jan

    What are you trying to do?
    The message says that you need to pass a PopupMenu to add (you are calling add on the Canvas). So, apparently, kaartje is NOT a PopupMenu (or subclass). What does Kaart look like?

  • Question about class icons

    So I learned today that a child class's icon is created by merging the child's icon as displayed in the class properties with the parent's icon as it appears in the parent's properties (the child's icon being the top image in the merge and the parent's the bottom). This isn't obvious from normal operation since the default icons are the same size and thus the child's icon perfectly overlaps and thus displaces the parent's. However, I drew an icon that extends a little bit beyond the bottom of the border of where the default icon normally goes (in the parent icon). This change was propogated to my numerous child classes, and now the icon is cut off on like 100 vis and it looks dumb.
    Technically, this doesn't change anything about my program. Since I never actually place the child vi's on a block diagram, I never see the icons except when editing the child vis or when they are calling each other (one child vi calls the other, which is rare). The code is only brought into the main vi via dynamic dispatch. That said, I'd love to know if there is a way to override the default behavior of how labview builds these vi icons. It's driving the pedant in me crazy.

    Hi majoris
    could you post an example of this so I can look at it more closely?
    Joe Daily
    National Instruments
    Applications Engineer
    may the G be with you ....

  • Academic Question about Classes Method and Constructor

    Given the similarity between the Constructor class and the Method class, why don't they have a common super class for the methods they have in common that are unique to them?

    sledged wrote:
    jschell wrote:
    sledged wrote:
    I've found that the most common reason for invoking a constructor or method through reflection is because you don't know what you need until runtime, commonly because what you want can vary based on context, or is otherwise being specified external to the bit of code that uses reflection. Not true. The fact that I don't need it until runtime never means I don't know what I need.Never? Then your experiences with the reflection API have been different than mine. Either that or I wasn't very clear. Let's take Apache Commons BeanUtils;
    It doesn't matter how you access a class. You can't use it unless
    1. You have a goal in mind
    2. That object in some way fulfills that goal.
    3. You know how that object fulfills that goal.
    And as I already pointed out you can't use a JFrame for a JDBC driver. Simple as that. Nor can I create a new class that implements, for example, ProC (Oracle method to embed access into C code) using my own idiom despite that it provide database access. It MUST match what jdbc expects.
    Sometimes it's not even clear before runtime whether a constructor's needed or a method.
    I disagree. That isn't true in any OO language.Perhaps not out the box, but it can be true when using certain tools built from the OO language. Let me continue using the Spring framework as an example. It does not know whether to use a method or a constructor to instantiate any bean defined in the XML configuration metadata until that XML file is read and it determines whether or not a given bean definition has the "factory-method" attribute. The XML file in not read until runtime, therefore with any given bean defined therein, Spring does not know until runtime whether to use a constructor or method.Not apt at all.
    As I already said those are two different idioms. Spring supports them because they are used to solve different problems not because they wish constructors didn't exist.
    >
    The basis of OO is the "object". You can't have a method without the object in the conceptual OO model. (And in Smalltalk that is always true.)
    True, but one may not always care how the "object" is provided. When the method [Properties.load(InputStream)|http://java.sun.com/javase/6/docs/api/java/util/Properties.html#load%28java.io.InputStream%29] is called, it isn't going to care whether the InputStream argument was instantiated by one of the FileInputStream constructors, or if it came from a [URL.openStream()|http://java.sun.com/javase/6/docs/api/java/net/URL.html#openStream%28%29] method call. It'll work with either regardless of their respective origins.
    That of course has nothing to do with anything. Unless you are suggesting that construction in any form should not exist.
    A factory is not a constructor.I'm not saying it is. I'm just pointing out a number of the similarities between the two.
    So? There are many similarities between RMI and JDBC but that doesn't mean that they should be the same.
    With your argument you can claim that construction doesn't exist because any method, regardless of intent, that uses 'new' would eliminate the need for construction. And that isn't what happens in OO languages.I wouldn't claim that construction doesn't exist in any OO language. But I do know that in ECMAScript construction exists on the basis of whether or not a method is called with the 'new' operator. So in ECMAScript a single method can also be a constructor.
    And in C++ I can entirely circumvent the object construction process. Actually I can do that in JNI as well.
    I would still be a bad idea.
    >
    They are not interchangable.Normally, no, but with a high enough level of abstraction, they can become interchangeable. Again, the Spring framework is a great example. It doesn't care if a method or a constructor is used, and it won't know which one has been chosen until runtime. I don't even think Spring checks the return type of a method, so you could use a void return type method. (Although I don't know what that would buy you because the bean would always be set to null, but still...)
    No.
    Based on that argument every possible programming problem could be solved by simply stating that one must implement the "doit()" method. One just need to generalize it enough.
    Different APIs exist because there are in fact differences not because there are similarities.
    Over generalization WILL lead to code that is hard to maintain. Actually generalization itself, even when done correctly, can lead to code that is actually more complex.
    Because construction is substantially different than calling a method. In all OO languages.Yes, construction is different, but the actual call to a constructor and a method is only syntactically different with the presence of the 'new' operator. With reflection the difference is between calling Method.invoke() and Constructor.newInstance(), and, as I mentioned earlier, there's enough similarity between the two methods that they could be called by a single method specified by a common super class.Which does not alter the fact that the process of achieving the result is fundamentally different.

  • Question about class PackedInteger.

    Dear All,
    i was searching for sth that can read an integer by using FileInputStream , i mean to take it in the form of an integer not bytes as usual , and i found this class called PackedInteger on that link :
    http://www.oracle.com/technology/documentation/berkeley-db/je/java/com/sleepycat/util/PackedInteger.html#readInt(byte[],%20int)
    mm actually i'm not sure about the source of that class , or who published it , alsoo i'm not sure if it would be useful in my case ,
    can any body help me ?, if u have any ideas about how to read and write inetegrs from to files i would be grateful to hear from u .
    thanks in advance.
    Regards,
    D.Roth

    hey guys , i found this also , what do u think ?
    readUnary
    public int readUnary()
    Reads a unary integer from the already read buffer.
    Returns:
    the decoded integer
    , in a class called BitFile .

  • Some question about java Runtime!

    I have some jar files, such as class.jar resource.jar.
    I hope to compress them to a single file.
    The file can be run like this, java -cp . filename.
    Anyone can help me!!!

    You need to have a manifest for your jar which specifies which main class to start. You can take a look at the docs to see how to go about doing this.

  • Question about accessing Runtime MBean server

    I would like to access the Runtime MBean server, and I've read this link: http://e-docs.bea.com/wls/docs91/jmx/accessWLS.html#1119237
    I want to access this from within my EJB application. My WLS 9.1 setup is simple (it's a Single Server Domain), and the class which is attempting to get to the runtime MBean server is from a stateful session bean. The Bean class is in a Jar which is deployed within an Ear as part of an ELB module.
    After reading "If the classes for the JMX client are located in a J2EE module, such as an EJB or Web application, then the JNDI name for the Runtime MBeanServer is", I expected to use the JNI name java:comp/jmx/runtime. But this failed.
    What worked was the other address specified (java:comp/env/jmx/runtime).
    So, apparently this means that "If the classes for the JMX client are located at the top level of an enterprise application (that is, if they are deployed from the application's APP-INF directory)"
    So, I'm not sure what this means? Can someone clarify when each address is available and when it's not? The existing explaination in the doco doesn't make sense to me. My application is defined as part of an EJB module, yet I can't use the JNI name for an EJB module?
    Thanks for any help,
    Ed

    It's called DNS registration.
    You need to talk with your network engineers or someone who manages your public website.
    We did our DNS registration of our Portal site through the telecom company who provides our office with Internet access.
    Our portal URL from the Internet is:
    https://portal.opnext.com/pls/portal
    If you can access it and want to log in using our "demo" ID, please send me an e-mail requesting the password.
    Eric
    [email protected]

Maybe you are looking for

  • ACS and same username for multiple users (max sessions)

    Hello, I have created four user groups and four users. Each user is in its own user group and each usergroup have its own ip pool. The problem is that multiple sessions is not always (works random) possible even if the max session is set for group to

  • Java 1.5 in Snow Leopard

    So Java 1.5 is deleted from Snow Leopard as I have just found out, to my cost. I have a Java application that requires Java 1.5 in order not to crash randomly (Oxygen-XML) and, more seriously, I do Java development work for platforms where 1.5 is req

  • Java advanced queue MDB class usage

    Hello, Loads of questions about JMS AQ and MDB. I have not found anything that tells you how to use the oracle.jms classes within a MDB's directly. Do I just cast the message to a AQMessage and retrieve from there? I have found plenty of documentatio

  • HT5037 I photo with the doesn't recognize the down load. What do I need to do?

    Can't get IPhoto to work- the download I did will not open I Photo-

  • Album Art Display question...

    Hello, I am able to sync my songs onto my nano with the album art from ITunes, but when the song plays, the art on the screen is very small. I thought that it would fill the whole screen. Is there a setting or some way to get the album art to fill th