New Version of WinRun4J (0.4.3) Available

Head over to the WinRun4J Sourceforge Page to download.

This includes the following fixes/improvements:

  • Fixed loading issue with Java 7
  • Added a standalone java service wrapper

Edit: Also note that the source code for WinRun4J has now moved to GitHub. Head over to the WinRun4J Github Page to view/download/fork.

Advertisement

21 Responses to New Version of WinRun4J (0.4.3) Available

  1. Chris says:

    Hi Peter,

    I ran into a problem using WinRun4J with connecting to Oracle UCP connection pool. I have a stripped down sample program I can send to you and the errors I am getting. Can you send me an email to clankest8-at-hotmail.com

    Chris

  2. Philippe says:

    Hello,

    I’m using winrun4J-0.4.3. I was able to install the demo and its running (it logs the Windows Events). But when I try with a custom jar, the service don’t want to start; I get that error “Error 1053: The service did not respond to the start or control request in a timely fashion.”. [I tried with a standard jar and with a runnable one.]

    Can someone send pinpoint my mistake?

    Thanks!

    Philippe

    File:
    ca.telecine.WinRun4jTutorial.v0.01.jar
    service.exe
    service.ini
    WinRun4J.jar

    INI:
    service.class=ca.telecine.WinRun4jTutorial.WinRun4jTutorial
    service.id=WinRun4jTutorial
    service.name=WinRun4jTutorial
    service.description=Test WinRun4jTutorial.

    classpath.1=*.jar

    vmarg.1=-Xdebug
    vmarg.2=-Xnoagent
    vmarg.3=-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n

    Jar code:

    package ca.telecine.WinRun4jTutorial;

    import org.boris.winrun4j.EventLog;
    import org.boris.winrun4j.ServiceException;
    import org.boris.winrun4j.AbstractService;

    /** A basic service. */
    public class WinRun4jTutorial extends AbstractService{
    public int serviceMain(String[] args) throws ServiceException {
    int count = 0;

    while (!shutdown) {
    try {Thread.sleep(6000);}
    catch (InterruptedException e) {}

    if (++count % 10 == 0){
    EventLog.report(“WinRun4J Test Service”, EventLog.INFORMATION, “Ping”);
    }
    }
    return 0;
    }
    }

    • poidasmith says:

      Could you add a “log” INI setting to log the launcher messages to a file?

      Or set “log.output.debug.monitor=true” and then grab DebugView from http://technet.microsoft.com/en-us/sysinternals/bb896647

      Then report back with the information?

      Thanks,
      Peter

      • Philippe says:

        Hello Peter,

        I’m using the code from your tutorial at http://borisinc.wordpress.com/tag/winrun4j/ and I’m having a compilation error saying that “SERVICE_ACCEPT_STOP and SERVICE_ACCEPT_SHUTDOWN can not be resolve to a variable”. Do I need to create those variable? And with which values? [If you have a working exemple - source included - I'll appreciate it.]

        Thanks!

        Philippe


        public int getControlsAccepted() {
        return SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
        }

      • poidasmith says:

        Hi Phillippe,

        The Service interface (org.boris.winrun4j.Service) defines the constants so if you implement this interface they will be in scope in your class.

        Regards,
        Peter

  3. Jana says:

    Hey,

    I want to use winrun4J to run a jar-file as service. this jar needs two paramerter. how can I pass this paramater by start the jar as a service.

    thx and best regards

    jana

    • poidasmith says:

      You can add application parameters to the INI file (arg.1, arg.2). These will be passed to the serviceMain method.

  4. Robert Egglestone says:

    Thanks for WinRun4J! – it’s the only actively maintained launcher I’ve been able to find that allows the app to be run in the same process.

    I had problems with the embedded classloader failing to load resources, for anyone else running into the same problem, a simple alternative is to concatenate the jar on the end of the exe, and add itself to the classpath.

    myapp.ini
    classpath.1=myapp.exe

    build.xml

    I read about this approach a few years back, it’s not exactly good, but apparently it works because zips are indexed from the end of the file whereas exes start from the beginning.

    Cheers,
    Robert

    • Robert Egglestone says:

      WordPress stripped out the XML tags for build.xml, they were…

      concat destfile=”myapp.exe” binary=”yes”
      fileset file=”winrun4j.exe”
      fileset file=”myapp.jar”

  5. Alexy says:

    Hello.
    There was a problem at attempt to launch .jar as service. At creation of object from a packet .javax arises nullPointerException:

    XPathFactory xpFactory = XPathFactory.newInstance ();

    And, as JAVA application all stablly works.
    I will be grateful for the answer.

    P.S. Excuse me for my bad English.

  6. Johannes Correa says:

    Hello and Thanks for WinRun4J. After a little work i was able to run a service by extending the AbstractService class and keep a log of the execution.

    But, I have two issues:
    1. When i try to stop the service, it never stops. I have to kill the process manually at the task panel. What do I have to do into my service class to handle properly the stop signal?
    2. I have certain business logic conditions that i have to check before the service logic start. I need to stop the execution and send a signal to windows that the service has not started properly. My first attempt was to throw a ServiceException but in Service Manager the service still appears to be initiated successfully. Should i have to return a value different from 0? Should i have to set the ‘shutdown’ variable to true?

    Thanks for your help.

    • poidasmith says:

      I have a few fixes queued related to starting/stopping services and will hopefully release a new version in the next couple of days.

      For point 2, you could try simply calling System.exit() with a non-zero exit code.

      • Johannes Correa says:

        Thanks for your answer.
        First, I will wait for the new version to try it, because my temporal solution was to apply a System.exit() at the end of the serviceMain method.
        For point 2, that is what i am doing right now but the problem would be that Windows would show an error message like “the communication with service has failed”, not that the service has not started successfully, which it would be the expected scenario.
        Finally, i have a question: what’s the difference between controls STOP and SHUTDOWN?

  7. jensen says:

    Is the WinRun4j plugin for Eclipse known to be functioning correctly? It appears that I have added it to Eclipse as a plugin, but Eclipse cites the WinRun4j version as 0.1.3 (as opposed to 0.4.3), and the Eclipse “Run As” list doesn’t include WinRun4j as an option. (Only the standard run as “java application” is present.) I’m using Eclipse version 3.3.2.

    • poidasmith says:

      The Eclipse plugin is versioned separately – 0.1.3 is the latest version. Actually, this is bundled with an older version of the launcher (on my todo list) – but this can be changed easily by replacing the files under:

      [ECLIPSE_DIR]\plugins\org.boris.winrun4j.eclipse_0.1.3\launcher

      I assume you mean eclipse 3.6.2? I haven’t tested on a really old version of eclipse for a while now.

      Also, do you see the preferences under Window – Preferences – Java – WinRun4J?

    • poidasmith says:

      Just checked the manifest – it requires at least 3.4.4. I’ll try to get a build out without this restriction (don’t think it really needs that version).

      EDIT: actually, double-checked and it does needs a few features from that version. Will update the site to reflect this.

  8. stephenG says:

    Three things:
    1) Great product. Easy to setup and use. Thanks for creating it
    2) We were getting the dreaded 1053 error with our service. It turns out that we had left the main.class in our ini file and once we removed that, things worked fine.
    3) Is there a way to get the plug-in to produce a service? Can I get the export tool to read an ini file in my project and embed it into the .exe? Right now we have to export the exe without the ini embedded and then manually copy our INI settings from a text file into the one produced by the plug-in. Naturally, these changes get overwritten every time we do the export.

  9. Tom S says:

    Please add a link to the javadocs (http://winrun4j.sourceforge.net/javadoc/org/boris/winrun4j/package-summary.html) to the SourceForge home page – they are there, but as-is you just have to know it (or do a Google search) to see them.

  10. Sangaran says:

    Hi

    I have installed Winrun4j for eclipse. I updated the latest version of winrun4j by coping the latest version 0.4.4 into launcher folder of eclipse. I ran the program as winrun4j application inside eclipse it says failed to load JVM. I am using jre 7. Also when I export as winrun4j application it runs properly. but when i make it as service it starts normally but fails to stop giving 1053 error. Eclipse version 3.7.1

    I have wrote a test service class.
    ——————————————————————————-
    package com.backgroundservice;

    import org.boris.winrun4j.AbstractService;
    import org.boris.winrun4j.ServiceException;

    public class BackgroundService extends AbstractService {
    private volatile boolean shutdown = false;

    public int serviceMain(String[] args) throws ServiceException {
    BackGroundProcess bp= new BackGroundProcess();// not a thread
    bp.initializeLogger();// logger initialization
    while (!shutdown) {
    try {
    bp.run();
    Thread.sleep(60000);
    } catch (InterruptedException e) {
    e.printStackTrace();
    }
    }
    return 0;
    }
    }
    ———————————————————————————-
    My service.ini file content as follows.

    log=log.txt
    log.level=info
    log.overwrite=true
    service.class=com.backgroundservice.BackgroundService
    service.id=BPS
    service.name=BackgroundService
    service.description=Test Background Service.
    service.startup=auto
    classpath.1=*.jar

    please let me know what could be the issue. thanks in advance

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.