Run windows services from java application

can java application run a windows server
i have a web server that runing using tomcat and mysql
can i make a icon in the systray
that give me the option to (using a menu)
run the server ,wicth means : tomcat and mysql are runing
stop the server
get tomcat stacktrace in a window
i was thinking about runing tomcat and mysql as services
and write the systray application using java,
the systray application should acces window services ,
and run/stop requierd services.
what happend on a machine thar runs linux?
thanks
shay

Ok .so it's will be a diffrent way under linux..
for systray i will use http://systray.sourceforge.net/
and for services i'll use the
"net start <Service>" and "net stop service"
i need to keep track on the service status
so my Systray status will be updated
what is the command for getting the status of the proccess
thanks shay

Similar Messages

  • Start and Stop a Windows Service From Java

    Is there any way to start and stop a Windows service from Java? The only post I found on it (http://forum.java.sun.com/thread.jspa?threadID=647509) had a link to one of the many aps that allow Java programs to be services, which is not what I am interested in doing.
    I am attempting to get data from performance counters from the Windows Performance Monitor into a Java ap without using JNI. I can get the data from C++ or a .net language pretty easily and was going to create a service that would listen for socket requests and feed back the data. However, I'd like to start and stop that service when my java code starts and stops. Is this possible? Would it make more sense to just use a .exe and Runtime.exec()?

    If it's only to start or stop a service then you could use the net command without any need for JNI.import java.io.*;
    public class MsWinSvc {
        static final String CMD_START = "cmd /c net start \"";
        static final String CMD_STOP = "cmd /c net stop \"";
        public static int startService(String serviceName) throws Exception {
            return execCmd(CMD_START + serviceName + "\"");
        public static int stopService(String serviceName) throws Exception {
            return execCmd(CMD_STOP + serviceName + "\"");
        static int execCmd(String cmdLine) throws Exception {
            Process process = Runtime.getRuntime().exec(cmdLine);
            StreamPumper outPumper = new StreamPumper(process.getInputStream(), System.out);
            StreamPumper errPumper = new StreamPumper(process.getErrorStream(), System.err);
            outPumper.start();
            errPumper.start();
            process.waitFor();
            outPumper.join();
            errPumper.join();
            return process.exitValue();
        static class StreamPumper extends Thread {       
            private InputStream is;
            private PrintStream os;
            public StreamPumper(InputStream is, PrintStream os) {
                this.is = is;
                this.os = os;
            public void run() {
                try {
                    BufferedReader br = new BufferedReader(new InputStreamReader(is));
                    String line;
                    while ((line = br.readLine()) != null)
                        os.println(line);
                catch (Exception e) {
                    e.printStackTrace();
    }Regards

  • Running exe files from java applications

    Hello All,
    Is it possible to run executable files from java applications?
    I need to run an exe file on the client from the server machine, the exe could reside on either the server or any other machine on the LAN. Is it possible to specify the path of where the exe resides, and run it on a client machine?

    HI,
    I tried to launch a MS Word application using runtime.exec but it gives me some problem
    The foll. code to launch a txt file using notepad works.
    Runtime rt = Runtime.getRuntime();
    String[] callAndArgs = {"notepad.exe","C:\\coo7\\wizard.txt"};
    Process child = rt.exec(callAndArgs);
    However, oif I try to launch a MS Word application, it asks for the entire path of WINWORD.exe, (unlike just specifying notepad.exe as the first argument in String[] callAndArgs) and this can vary from one machine to another.. how do I get around this?
    The foll. code snippet works but the complete path of where WINWORD.exe might be installed on any machine, is not fixed:-(
    Runtime rt = Runtime.getRuntime();
    String[] callAndArgs = {"C:\\Program Files\\Office\\Office10\\WINWORD.exe","C:\\coo7\\wizard.doc"};
    Process child = rt.exec(callAndArgs);
    Any idea/suggestions pls..

  • Running a script from java application

    How do I execute a script (sms_setver which requires parameters such ms9qa) from java application using Runtime.exec(). I tried Runtime.getRuntime().exec("sms_setver ms9qa"). But, I get this error:
    Caught: java.io.IOException: CreateProcess: sms_setver ms9qa error=2

    Same way it is actually run from a console command line.
    If you are doing this in windows then it might be using the extension to determine how to run it. If from unix then it might be using the shebang line.
    At any rate figure it out and use that instead. Usually it involves either explicitly using the shell or some other executable and the script is a parameter to that process.

  • Monitoring windows services from JavaI Know how to

    I know how to start and stop services in java, but how can I see if a process is already stared or is starting?
    Thx

    You'll need to make a call to a suitable Windows program using Runtime or ProcessBuilder methods, or use JNI (Java Native Interface.) From Wikipedia:
    (JNI) is a programming framework that allows Java code running in the Java virtual machine (JVM)
    to call and be called[1] by native applications (programs specific to a hardware and operating system
    platform) and libraries written in other languages, such as C, C++ and assembly.

  • Querying windows service from Java

    Hi All,
    i have a java web application running on jboss that does data collection by querying different windows processes like MSSQLSERVER, IIS availability etc.
    The problem i am facing is that my application is returning a negative result for the above services but when i run the query from command prompt i get a positive result. I dont understand why this happens.
    would really appreciate a response.

    Is query this from java Runtime.exec and from command prompt different? My code creates a string of sc \\<server> query W3SVC and calls this like:               String cmd = "sc "+ " \\\\ " + serverIPOrHostName + "query"+ service;
                   p = r.exec(cmd);
                   inp = p.getInputStream();
                byte[] dataInput = new byte[320];
                inp.read(dataInput);
                String inputData = new String(dataInput);
                //Logger added to read the service response.
                logger.info(inputData);
                //Checks for specified sequence of characters in the string and
                //returns boolean.
                if (inputData.contains(SERVICE_RUNNING)) {
                     result = 1;
                } else {
                     result = 0;
                }My reasoning is that if i cant do it in java because of some security policy then i should not be able to do it in command prompt too? But that is not the case. I can do it over command prompt but not from java code!
    If this is a windows related issue, how should i proceed to debug it? how can i provide access to my java code to do this?
    I happened to check out one site http://www.kbalertz.com/kb_Q323790.aspx where it says that "The File and Printer Sharing for Microsoft Networks component must be turned on for many remote-management functions to work. "
    But this looks like a very trivial (although i dont know much about windows security policies).
    thanks,
    Dilip
    PS: Thanks for looking into the mail and responding.

  • Running .bat files from java applications

    Has anyone tried to run a .bat file from a java application?
    I know I can run java commands by getting the application's runtime, but I've a number of *.bat files I like to run from the application without having to extract the commands from the .bat files.
    thks,

    Crikey! You were answered very shortly after you posted your question, and you STILL haven't bothered to come back. And are you going to create a new userid the next time you ask a question, since bat2004 seems tied to this particular question?

  • How to run a vi from Java application?

    I am passing data to a vi from my java swing application using data socket bean but I have to manually open and run the vi. How can I programatically open and run the vi from my java application without using ActiveX automation server?

    I don't know Java but if you can issue a shell command then you can run the VI with the command line:
    "\labview.exe" ""
    You have to set the VI to "Run when opened". The VI will run each time the command is issued, even if the VI is already opened.
    LabVIEW, C'est LabVIEW

  • Cannot run batch program from Java Application

    Hi All,
    Im trying to run a batch file under windows from my Java Program. The batch file is located in the following path:
    C:\Program Files\MyApp\runme.bat
    The above-entioned path contains white space which is not allowed in NT.
    Im trying following code:
    import java.io.*;
    public class Exec {
    public static void main(String args) {
    try {
    Runtime.getRuntime().exec("cmd /c start C:/Program Files/MyApp/runme.bat");
    }catch(Exception ex){ ex.printStackTrace();}
    How to run this file?
    Thanks in advance.
    Ketan Malekar

    or use the overload that takes an array of strings as argument
    String[] command = {"cmd", "/c", "start", "C:/Program Files/MyApp/runme.bat");
    Runtime.getRuntime().exec(command);

  • How to run windows program through java applications.

    pls help me!!!!! code RED!~

    C:\Documents and Settings\student\Desktop\Running.java:12: cannot resolve symbol
    symbol : variable JMStudio
    location: class Running
    String path="C:/Program Files/MF2.1.1/bin"+JMStudio;
    ^
    1 error
    this error is generated
    any idea on how to solve it?

  • Can we run EXE file/ Another Java Program from Java Application? How?

    Can we run EXE file and another java program from java application?
    Thanks in advance

    Example running adobe acrobat
    String command = "C:\\Program Files\\Adobe\\Acrobat 5.0\\Reader\\AcroRd32.exe /t "+selectedDocument+" \\\\CONTROL\\HP LaserJet 4L";
    Runtime rn = Runtime.getRuntime();
    Process process = rn.exec(command);
    process.waitFor();rykk

  • Best way to create a Windows service from a LabVIEW executable​?

    What would be the best way to run a LabVIEW executable as a service? I needed this recently and I think I have set up such a service using srvany.exe from the Windows 2003 Resource Kit, but that seems like a bit of a hack. The Kit is not offically supported in Server 2008, but seems to work. I don't know about Server 2012 or beyond.
    So what would be the "proper" way of going about creating a Windows service from a headless LabVIEW application?

    The proper way is to interface to the according Windows service control API. That is however not a trivial task to do. We used to sell a LabVIEW toolkit which supported a full interface to this, but it's not currently actively marketed.
    srvany.exe is sort of a hack but works reasonably well for most use cases, as long as you do not need any further interaction with the service manager interface in Windows than to start and stop your service.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Storing chinese in client odb from java application

    Hi all,
    first i like to thank Greg Rekounas for his wonderful support and contribution....
    This is my server setup.
    os-windows 2000 sp4
    db-oracle 9ir2 (unicode with AL32UTF8 charset)
    lite-oracle10g r2 (with latest patchset)
    nls_lang- AMERICAN_AMERICA.AL32UTF8
    storing and retriving chinese in oracle 9i database from isql*plus works.
    lite configuration.
    1. In $OLITE_HOME\mobile_oc4j\j2ee\mobileserver\applications
    \mobileserver\setup\common\webtogo\webtogo.ora file edited the JAVA_OPTION
    to:
    JAVA_OPTION=-Djava.compiler=NONE -Dfile.encoding=UTF8
    2. In $OLITE_HOME\mobile_oc4j\j2ee\mobileserver\applications
    \mobileserver\setup\dmc\common\win32.inf file, added the following:
    a. In the <file> section, added the following:
    <item>
    <src>/common/win32/olilUTF8.dll</src>
    <des>$APP_DIR$\bin\olilUTF8.dll</des>
    </item>
    b. In the <ini> section, added the following:
    <item name='POLITE.INI' section='All Databases'>
    <item name="DB_CHAR_ENCODING">UTF8</item>
    </item>
    <item name='POLITE.INI' section='SYNC'>
    <item name="DB_ENCODING">UTF8</item>
    </item>
    published the application developed in java using packaging wizard.
    downloaded the client in the pc with the following config:
    windows 2000 (english)
    nls - default.
    installed chinese language support.
    tried to access 9i database from isql*plus and stored & viewed chinese characters sucessfully.
    tried to store a chinese character from java application in the client odb -- failed.
    values are getting inserted from the application but when i view them back it shows & # 2 6 0 8 5 ; (i have included a space in between all 8 characters.
    but when i copy this no and paste in msword it shows 日(chinese character)
    i dont know the exact reason for the above scenerio...................
    Also please help me on this too.......
    why can i store & view chinese characters sucessfully in isql*plus from the client machine while i cannot do the same on client odb from java application even though the lite config are done to support utf8?
    is anything i left out?
    should i do any codes changes in java?(java application is of verision jdk1.4_13)
    Thanks,
    Ashok kumar.G

    Sorry for late replay!! in the SharePoint server both the Claim based and Classic mode is enabled in the server, but still I want to get authenticated via Classic mode just like it happens in SharePoint  2007 and 2010, so do i have to use a different
    set of classes to do that if yes can you please tell me those ?

  • Calling a Web Service from Java

    Our java guru (who is out sick....AHHHH) created all the calls that are needed to access the web service that he has running. For example the call getLongList(String user, String password) will return a list of all outstanding transactions. He made a jar file that has service has class files for PortType, Service, Service Locator and Soap Binding stub.
    How do I call this web service from java? Do I have to import it into my classpath? or just call these parameters from within my java code?

    never mind...i got it

  • WEB SERVICE FROM JAVA CLASS

    Hi,
    I'm new to BPEL and I've a problem: i need to create a WEBSERVICE from Java class.
    This Java class contain functions to call other functions in other packages.
    These last function contain sql query: it's an java "interface" application between BPEL and an EXTERNAL Oracle database 10g.
    I want to create one WEB SERVICE from this application and i followed the steps (right click, menù, create j2ee webservice, etc) i obtain error:
    VALIDATION FAILED --- Files at the following URLs cannot be modified:
    File:/C:/OraBPELPM1/integration/jdev/jdev/mywork/RichiesteWebService/ARRICH/app/src/controller/MyWebService1.webservice
    File:/C:/OraBPELPM1/integration/jdev/jdev/mywork/RichiesteWebService/ARRICH/app/src/controller/IMyWebService.wsdl
    File:/C:/OraBPELPM1/integration/jdev/jdev/mywork/RichiesteWebService/ARRICH/app/src/controller/MyWebService1.dd
    Show the java class "interface":
    package controller;
    import java.util.*;
    import java.sql.*;
    import domain.*;
    import dao.*;
    import utility.*;
    public class Request_Incoming_Controller {
    public Request_Incoming_Controller() {}
    /* Update StatoTurismo */
    public static String aggiornaStTurismo(int numIncoming, String tur) {
    GregorianCalendar dp = FormatoData.dataDaDate1("00/00/0000");
    Request_Incoming ric = new Request_Incoming(numIncoming,"","",dp,dp,"","","",0,"",tur,"");
    // try {
    if(ric.aggiornaTurismo()<0)return "NO";
    return "OK";
    // } catch (SQLException ex) {
    // System.err.println("Eccezione durante l'aggiornamento "
    // + ex.getMessage()); }
    /* Update StatoCassa */
    public static String aggiornaStCassa(int numIncoming,String cash) {
    GregorianCalendar dp = FormatoData.dataDaDate1("00/00/0000");
    Request_Incoming ric = new Request_Incoming(numIncoming,"","",dp,dp,"","","",0,"","",cash);
    // try {
    if(ric.aggiornaCassa()<0) return "NO";
    return "OK";
    // } catch (SQLException ex) {
    // System.err.println("Eccezione durante l'aggiornamento "
    // + ex.getMessage()); }
    /* Lettura del NumIncoming assegnato dal sistema dopo il caricamento della
    * richiesta in base alla matricola del Dipendente
    public static int caricaNumDaDip(String dipendente){
    Request_Incoming ric = new Request_Incoming(0,dipendente);
    // try {
    ric.trovaNumIncoming();
    return ric.getNumIncoming();
    // } catch (SQLException ex) {
    // System.err.println("Eccezione durante l'aggiornamento "
    // + ex.getMessage()); }
    Can Anyone help?
    Is urgently.........thanks
    Daniele

    You should try to post it there:
    http://forums.oracle.com/forums/forum.jspa?forumID=97
    But if I look at the error, it looks like some files are Read-Only. Maybe you should check if they are or if you have the appropriate rights on the folder.
    Good luck

Maybe you are looking for

  • Yoga 2 Pro touch screen no longer working & intermittent USB issues

    Hey. Got the Yoga 2 Pro 2 weeks ago. The touchscreen does not work at all today. I've reset/shutdown many times. Here are the issues I have had in order of occurrence: - webcam intermittently not coming up during verifice login on resume from sleep (

  • Remote Desktop Client 8.1.3 Display Issue

    We're running Microsoft Remote Desktop 2012R2 services including a Gateway/Connection Broker/Licensing server and  Remote Desktop Session Hosts servers.  Our clients include Windows systems, iPads and iPhones. Since the upgrade to Microsoft Remote De

  • Video, si. Audio, nada.

    I've been able to insert video into an InDesign document and export to PDF but I can't get audio to work. What do I need to do to get the PDF video to play the audio.  I've checked the original video files (H.264) and the audio plays fine.

  • Pictures in Touchsmart (TS) Folders

    The TS picture folders are different from the folders in Windows photo gallery--including the dates on the folders. How do I correct so that the TS folders are organized the same as Windows Photo Gallery? I have HP TS IQ546t PC. Thanks! MountainMama

  • Stock trasnfer from plant unretricted use stock to customer consignment

    We are trying to transnfer stock from unrestricted used stock directly to Customer consignment stock in MM using MIGO transaction (not via SD consignment fillup),  is this possible using tcode MIGO and what is the movement type? Please help.