Run an application as background process - java

I have developed a Java application. I want to run it as a background process.
It should not be displayed as Running Application in task Manager, but it should be displayed in Processes List.
Help me out.
Regards,
Jigar

I've edited your question since it's a pure windows issue.
I would suggest you to take a look at ways to run your java application as a windows service.

In addition to Command Prompt option given by Rafael Roman, we can also schedule task through Control Panel -> Scheduled Tasks -> Add Schedued Task. For more info:
http://technet.microsoft.com/en-us/library/cc738106(v=ws.10).aspx

There's no need for complex solutions.
use the at commando and create a bat that runs your program.
type in any cmd windows:
at 10:00 c:\run_my_script.bat
remember to replace 10:00 to a time 1 minute after the current time of your machine

Related

CronJob Runs but Does Not generate output

I have a shell script which executes a java class and it is supposed to run weekly using Cronjob.
Last few days it hasn't been working as expected.
It does not generate any kind of logs or output.
checked /var/logs ,the cronjob looks like it is running on the time it has been scheduled to.
Also , if i manually run/execute the java class it works perfectly fine.
Any idea why cron isn't working?
PS: A similar shell script scheduled at a different time running the same java class is working without a problem.
Your question is if we have any ideas why cron isn't working. Based on what you wrote, I think that you probably recently moved the input or output file. It may run when you execute it manually but cron runs from a different location, so you have to use full paths to all files and commands, please try this. Source: Experienced same problem
Best Regards

java - how reflect a long running workflow process in GUI?

I have a workflow of functions that eventually lead to a deployment of something.
the steps are as followed:
run a python script the produces some output.
run a bash script that copies this output to a given location
run a bash script (depending on the output of 1,2) that runs a java program (running make take few hours)
run another bash script on this output - final step
i want to be able to initiate this workflow from a GUI giving a set of parameters.
Then, I want to be able to get status reports of each step - so that the running user will know which step is currently running.
The main issue here is that each of the steps may take long time to finish.
My experience with developing GUI in java is limited.
Any advice on the direction I should go to?
If you really want to write this in Java, then you should try to find a good wizard library. See this question for some details.
Then, if at all possible that your scripts provide some feedback like the percentage of the operation completed then you could have a JProgressBar for each step independently and an overall one to show the user an idea of how much is done at any moment.

Java program running in background

I have a simple java program which is just a single piece of code that reads from a database and modifies the contents of the database based on certain conditions. Now, what I want is that this program should start automatically at the startup and silently run in the background unless someone kills it from the task manager.
I have never done something like this before and don't know exactly how to go about it. Can someone help me out as to how this can be done?
Thank you..
Follow the these steps to do the job :(Assuming you are using windows and jre is installed )
First compile your java program and place the class file at one location.
Now create a bat file and place java LOCATION TO THAT CLASS FILE/MyProgram in that.
Put your bat file in start up programs
Restart the system, you will get your program running in back ground..!
Hope this will help you.
There are two problems here
How to add this program to the startup
Windows - Run Java application at Windows startup
Linux - Linux start-up script for java application
Run the program as a daemon (background process)
Simplest way to do is using a while loop and sleep for required time interval in the while loop. Then perform the database
operation.
Also for windows, you can check this JSL
http://www.roeschter.com/
Thanks.
first create you jar bash and then add it to you crontab task list.

JAVA: Opening an application when the user starts their computer

I have an application which has a purpose to run when the user first runs their computer.
However, I'd like to make a check box on the app that enables/disables the application loading when the system is started. Is there any way to do this?
Thanks
I recommend you to create a service under windows. My suggestion is http://winrun4j.sourceforge.net/
This question has been discussed in SO time ago:
Code for Auto starting a java application on windows startup
Auto startup for java desktop application?
However, maybe the easier solution is to create a batch file,like suggested in the first link, to run your application as the user logs in.
If you want to enable/disable the startup through a checkbox, the first and simplest solution that comes to my mind is this: you can make a method, invoked by the checkbox listener, that edits the batch file and enables/disables the line used to run the application, in the batch file.
If you have Windows 7, read this tutorial.

schedule java program

I want to run my java program in regular interval , lets say, in every 3 hours. I am thinking to write a .bat file and put command to call java class. But what is the best way to run .bat regularly in windows xp. Thanks in advance. I dont want to use third party tool.
Windows scheduled tasks are built for exactly that purpose.
You can run things on multiple schedules (so you can get your every-three-hour behaviour) and you can get your code to run whether or not logged in.
The multiple scheduling is a bit tricky. You basically set it up as a daily task to start with but, near the end, it will ask you if you want to do advanced features.
Select yes then you can set up multiple schedules at that point.
If you want a pure Java Based solution you can try QUARTZ SCHEDULER. But as paxdiablo already mentioned, Windows Task Scheduler will do that as well.

Categories