Link to home
Start Free TrialLog in
Avatar of venishjoe
venishjoeFlag for United States of America

asked on

Writing Java Program to run as a Windows (NT) Service

Hi Experts,

I have a Java application which should run as a Windows (NT) Service. There are many tools
like Wrapper to do this. But how can I do this in my java code itself. It should be only using java, I cannot use languages like C along with Java. So is there any methods to do this?

Can you provide me with links or sample code or any valuebale tips?

Thanking You.
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

You can't do it without using some native code. You could use a batch file though and use the Windows scheduler to start it at startup
@echo off
java -classpath x\y\z YourProgram



Save the above as a batch file and have Windows scheduler execute it at startup
(or javaw)
Avatar of venishjoe

ASKER

I dont want scheduler to start it up. Basically my code is a proxy server and I need it as running as a service
So how to do with native code?
Avatar of Nick_72
Nick_72

You shouldn't try to write native code. Use the classes you've already referred to that already exist
Hi Nick_72,

The two links you mentioned is reffering to the Wrapper, which is a tool. But I dont want to use an external tool.

Hi zzynx,

Your Links also refer to tools.

Hi objects
Your link is also referring to Wrapper

Hi CEHJ,

Can you explain your statement more precisely?
>>Can you explain your statement more precisely?

What i mean is that if you don't want to implement my suggestion for avoiding 3rd party libraries (not quite clear why you don't) then you shouldn't reinvent the wheel by writing native code when that's what the 3rd party classes do. Simply use them
> Your link is also referring to Wrapper

It includes source code, use that as a guide to write your own :)
Hi CEHJ,
Well can you suggest some pre existing classes for this purpose?
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
venishjoe, shouldn't the poster of the link (Nick_72) get some points too?
Probably i think ;-)
Oh! Should be, Sorry guys!!
Well, you can ask to reopen this question:

1) Post a zero-point question in https://www.experts-exchange.com/Community_Support/

        Subject: Moderator Please Reopen
        Body: Please reopen this question:
        https://www.experts-exchange.com/questions/21421662/Writing-Java-Program-to-run-as-a-Windows-NT-Service.html

2) Once reopened you can re-accept using a split
Thank you very much guys for the concern, but it's alright with me :)
If you haven't posted already you can just leave it be.

Regards,

Nick