• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 711
  • Last Modified:

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.
0
venishjoe
Asked:
venishjoe
  • 7
  • 5
  • 3
  • +2
1 Solution
 
CEHJCommented:
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
0
 
CEHJCommented:
@echo off
java -classpath x\y\z YourProgram



Save the above as a batch file and have Windows scheduler execute it at startup
0
 
CEHJCommented:
(or javaw)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
venishjoeAuthor Commented:
I dont want scheduler to start it up. Basically my code is a proxy server and I need it as running as a service
0
 
venishjoeAuthor Commented:
So how to do with native code?
0
 
CEHJCommented:
You shouldn't try to write native code. Use the classes you've already referred to that already exist
0
 
zzynxSoftware engineerCommented:
0
 
venishjoeAuthor Commented:
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?
0
 
CEHJCommented:
>>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
0
 
objectsCommented:
> Your link is also referring to Wrapper

It includes source code, use that as a guide to write your own :)
0
 
venishjoeAuthor Commented:
Hi CEHJ,
Well can you suggest some pre existing classes for this purpose?
0
 
CEHJCommented:
The link posted earlier is to what is meant to be a good implementation:

http://wrapper.tanukisoftware.org/doc/english/introduction.html
0
 
zzynxSoftware engineerCommented:
venishjoe, shouldn't the poster of the link (Nick_72) get some points too?
0
 
CEHJCommented:
Probably i think ;-)
0
 
venishjoeAuthor Commented:
Oh! Should be, Sorry guys!!
0
 
zzynxSoftware engineerCommented:
Well, you can ask to reopen this question:

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

        Subject: Moderator Please Reopen
        Body: Please reopen this question:
        http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21421662.html

2) Once reopened you can re-accept using a split
0
 
Nick_72Commented:
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
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 5
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now