I recently developed a runnable jar file (JDK 1.8.31).
Then I used launch4j to convert it into an exe file and at last I used nssm to register the exe as service.
Both the jar and the exe executed well.
I set an administrator mode for the exe file before registering it as a service.
Also, in the properties of the service I set the "Log On As" to .\administrator
But, when I tried to start the service from the Services Window I got the following error message:
"Could not start the --service name-- on Local Computer. The service
did not return an error. This could be an internal Windows error or an
internal service error. If the problem persists, contact your system
administrator"
How can I understand what is wrong?
Thank you.
Related
I have developed an application in javafx. It works very well on my laptop even when I deploy it and run on my computer, but when I install it on another pc the application starts normally, but does not display any interface (the task bar it is present). When I run the .jar with java -jar monapp.jar command I have an error in console
error shown in the console
Please help.
Please see the steps I have followed below:
1) Start the Glassfish server in Netbeans:
2) Run the Netbeans project, which successfully browses to: http://localhost:8080/CRUDWebAppSQL/StudentServlet I am able to use the application.
3) Close Netbeans, which stops Glassfish (in preparation for the next step)
Then I try this:
1) Run the following DOS commands:
cd C:\Program Files\glassfish-4.0\bin
sadmin start-domain domain1
2) Message received saying server has started. Browse to: http://localhost:4848/ and login. Make sure that CRUDWebAppSQL is listed as an app.
3) Browse to: http://localhost:8080/CRUDWebAppSQL/StudentServlet which display a Glassfish 404 error
Why does step three produce a Glassfish 404 error? Does it have something to do with this: Where does glassfish save your class/project after deployment on Windows?
NetBeans is using a different mechanism to deploy your application to support hot deployment in comparison to a manual deployment.
To run the application without NetBeans first build the web application with e.g. with Maven mvn clean install to get the *.war file.
Start the Glassfish application server and either deploy the war file through the web interface or with command line asadmin deploy war-name
By the way I would suggest to update NetBeans to the current 8.2 release and have a look at Payara, which is a patched drop-in replacement for Glassfish: http://www.payara.fish/downloads
Netbeans glassfirsh server combine with Felix platform.
Download GlassFish Server Open Source Edition.
Unzip it and goto bin folder in the unzipped folder.
double click asadmin.bat
type start-domain
in this command you can start glassfirsh server
(you can find more command in google)
open browser and type http://localhost:8080/
click link as
go to the Administration Console.
it view "GlassFish Console".
in here you can deploy your web app.(Extension ".war" file)
I installed postgreSQL binaries in windows 7 32bit operating system; I can start the server from cmd but I cant run it as a windows service.
This is the error that I'm getting when I try to start the service manually:
"The postgreSQL service on local computer started and then stopped. some services stop automatically if they are not in use by other servces or programs"
All I need to do is; after booting to windows when I double clicked my java application I need to run my app smoothly without any database errors. I cannot do this because postgreSQL is not running as a windows service.
I found this in windows event viewer:
The description for Event ID 0 from source PostgreSQL cannot be found.
Either the component that raises this event is not installed on your local computer or the installation is corrupted.
You can install or repair the component on the local computer.
If the event originated on another computer, the display information had to be saved with the event.
The following information was included with the event:
postgres cannot access the server configuration file
"C:/Windows/system32/pgsql/data/postgresql.conf": No such file or directory
I googled about it but I was not able to find an answer.
Problem was solved
path to the data directory was wrong in windows service file.
So I delete the service file from this method:
1)Run Regedit or Regedt32.
2)Go to the registry entry "HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services"
3)Look for the postgreSQL service that you want delete and delete it.
4)reboot the computer.
After that open the cmd (Run as administrator) Go to the postgreSQL bin directory and run this command to create a new windows service:
pg_ctl.exe register -N "PostgreSQL" -U "NT AUTHORITY\NetworkService" -D "C:/Program Files/postgresql/pgsql/bin/pgsql/data" -w
This worked for me. Hope this will help.
This is a note for a normal user. If using an official installer it should has a build-in service,
Win+R and type services.msc
Search Postgres service based on the version installed,
e.g., "postgresql-x64-13 - PostgreSQL Server 13"
Click stop, start, or restart the service option
postgres cannot access the server configuration file
"C:/Windows/system32/pgsql/data/postgresql.conf": No such file or
directory
This looks like your working directory is C:\Windows\system32 and you are running postgres there and it looks for data/postgresql.conf.
Try changing the working directory or specifying -D C:\path\to\my\data.
So I am trying to set up an H2 database server. So I took the installer from their website ,
after getting the Path for windows fixed. If I run my bat as typical user the server launches , but when I try to connect it crushes because , writing a lock needs admin rights. So if I try run it as admin , I get ERROR: Could not find or load main class org.h2.tools.Console
That sounds like either
a classpath problem, if you are including the jar in your own application
or
a Windows ACL problem i.e. you're trying to access a part of the filesystem that your user cannot write to.
or
both of the above
How do I run a Java .jar file as a Windows service on a Windows 2008 server? I have a jar file called SomeJavaFile.jar located under the C:\SomeDirectory directory on a Windows Server 2008 box. I usually just run this jar manually in the command line with: java –cp SomeJavaFile.jar com.ctg.SomeJavaFile and I let it run 24/7.
The problem with our Windows Server is if it restarts I need to run it as a service so it will automatically start as a service upon startup, because our processing for Vistakon runs 24/7. I have Googled around and tried to use a service wrapper and the sc.exe command to create the service.
I put the wrapper service.exe in the C:\SomeDirectory\. I use the following command to create it: sc.exe SomeJavaService binPath= “C:\SomeDirectory\service.exe \”java –jar C:\SomeDirectory\SomeJavaFile.jar\”” type= own start= auto error= ignore. This creates the SomeJavaService service correctly but when I try to start it I get an error that says the service on Local Computer started then stopped.
Some services stop automatically if they are not in use by other services or programs. Do I need to alter my sc.exe command to have the exact previous working command line maybe, by adding in the com.ctg.SomeJavaFile? So should I change This jar should just run in the background and constantly poll/ping the C:/poll directory then if there is data present it processes the data and sends an export file to another directory.
I have used this same .jar file for years successfully and it hasn't changed, but I cannot get it to run as a Windows service. This is the site I use to get the service wrapper http://code.google.com/p/simple-service-wrapper/. Any help would be greatly appreciated!
"winsw" is the standalone version of the Windows Service installer shipping with the Glassfish Java EE reference implementation.
Works well, but is not a fully polished product - I have used it for exactly this purpose for a couple of years. Requires .NET in some recent version on the Windows machine.
https://github.com/kohsuke/winsw
I think that the best bet would be wrap your java app with Procrun of Apache Commons Daemon .
Procrun is a set of applications that allow Windows users to wrap
(mostly) Java applications (e.g. Tomcat) as a Windows service.
The service can be set to automatically start when the machine boots
and will continue to run with no user logged onto the machine.
As per my analysis,
The Idle Solution will be writing a VC++ (.net) Windows Service creation program to launch the .bat (that triggers the jar file)/.exe as a System service with all the required call back methods to SCM.
Note : 1. Wrapping the process with sc.exe / srvany.exe would not work as it does not have any call back process to the SCM (Service Control Manager). 2. And java service Wrapper is a third party API (many are LGPL licensed).
If you start your Java code from commandline by using java -j some.jar does it run until you terminate the program, or does it stop by itself?
There needs to be a NON-Deamon Thread, that is running all the time. A JVM will terminate, if there is no thread running, that is not flagged as daemon.
If you have a little budget, buy an installer tool. I use instll4j. With that tool, you can create service launcher and install them during instllation.
The following solution is working fine for me having OpenFire Connection Manager (which is a jar file) running as service on Windows Server.
Download and install the Non-Sucking Service Manager
I didn't use the batch made by OpenFire team, because it didn't work for me (dependencies not found error...) So, make a batch file with the following code :
#ECHO OFF
cd /D "E:\connection_manager\lib"
java -jar startup.jar
and save it as cm_startup.bat in the bin folder of connection manager.
After that you can create the service with NSSM.
So, open a cmd.exe and run the following command :
nssm install ConnManager "E:\connection_manager\lib\cm_startup.bat"
.
Doc & examples
More documentation and examples for the Non-Sucking Service Manager here : https://nssm.cc/usage Actually NSSM as a lot of options available.
Here is a more complexe example :
nssm install solr "%JavaExe%" -Dsolr.solr.home="\"%CD%\solr"\"
-Djetty.home="\"%CD%"\" -Djetty.logs="\"%CD%\logs"\" -cp
"\"%CD%\lib\*.jar"\";"\"%CD%\start.jar"\" -jar "\"%CD%\start.jar"\"