Running a command from a jar file


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Running a command from a jar file

  1. #1
    Join Date
    Mar 2006
    Location
    Canada
    Posts
    3

    Question Running a command from a jar file

    Hi, guys. I hope you can help me. I've already done some search and didn't find a satisfying answer. I know, its probably a very stupid problem, but I just don't know what to do.

    So, here it is:

    I've got an application which is silently running on a computer A. I've got also another application on a computer B. Using this application I can remotely restart/log of/shutdown computer A. The action is performed by shutdown.exe + parameters which I specify on the computer B. EVERYTHING WORKS PERFECTLY as long as I don't create *.jar files. Running from *.jar archives everything works up to the point when the shutdown command should be executed. I always end up with java.io.IOException: CreateProcess: shutdown.exe /r /t 60 /c "comment" error=2.

    I also know that Runtime.exec() is NOT a command line, so what should I do to make it run directly from *.jar?

    This restarts the computer A:
    HTML Code:
    Runtime.getRuntime().exec("shutdown " + receivedCommand + " /t " + delay + " /c \"" + comment + "\"");

    This allows the user of the computer A to abort the shutdown if necessary:
    HTML Code:
    Runtime.getRuntime().exec("shutdown /a");

    OS: Win Xp
    JRE 5.0 Update 6


    Thanks for any help.

  2. #2
    Join Date
    Apr 2005
    Posts
    9
    Couple of things to try:
    Are you sure that the file is running under the right permissions? Try running your program sudo or as admin. My thoughts being and I'm guessing maybe you java.exe or javaw.exe is running at higher permission then you .jar file. It seems to me like your getting held up when you try and create a new thread try exec-ing a different low level command.

    And is your Main-Class manifest attribute set correctly?

  3. #3
    Join Date
    Mar 2006
    Location
    Canada
    Posts
    3

    Lightbulb Can't work with System32

    Quote Originally Posted by hexaplus
    Couple of things to try:
    Are you sure that the file is running under the right permissions? Try running your program sudo or as admin. My thoughts being and I'm guessing maybe you java.exe or javaw.exe is running at higher permission then you .jar file. It seems to me like your getting held up when you try and create a new thread try exec-ing a different low level command.

    And is your Main-Class manifest attribute set correctly?
    It is probably a security issue. I can execute anything as long as it is out of the System32 directory. When I take (copy) shutdown.exe out of System32 it works perfectly. A possible solution is to put *.jar into System32, unfortunately, it's then impossible to run the program at all. Windows just don't want anything to mess with System32, even if I'm logged as an Administrator...

  4. #4
    Join Date
    Apr 2005
    Posts
    9
    Sorry I'm more of a unix guy can, have you tried specifying the fully qualified path? I'm hoping you succeed because I'm going to be doing the same thing in about a week.
    Last edited by hexaplus; 03-20-2006 at 07:26 PM.

  5. #5
    Join Date
    Mar 2006
    Location
    Canada
    Posts
    3

    Post Can't work with System32

    Quote Originally Posted by hexaplus
    Sorry I'm more of a unix guy can, have you tried specifying the fully qualified path? I'm hoping you succeed because I'm going to be doing the same thing in about a week.
    Yes. If it's not invoked from the command line, my Windows just doesn't want to run anything from the system32 directory. I can make a *.bat to run the program, but then end up with a console window hanging on the screen.

Similar Threads

  1. Database not properly created
    By Arjuna in forum Database
    Replies: 2
    Last Post: 07-25-2007, 03:22 AM
  2. Problems with URI in a jar file
    By alcdotcom in forum Java
    Replies: 4
    Last Post: 09-29-2005, 08:09 PM
  3. wav file fade in out help
    By jase_dukerider in forum C++
    Replies: 2
    Last Post: 04-14-2005, 07:48 PM
  4. How long before the next version??
    By _CAG in forum .NET
    Replies: 146
    Last Post: 08-12-2002, 10:40 PM
  5. Replies: 0
    Last Post: 08-22-2000, 10:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center