I want to install a monitoring system on a computer (the program is a jar file) and run it on start up every time any user logs on. However, I don't want the user to be able to terminate it since then it won't be able to be monitored any longer.
We have tried several ways:
Installing it as a service - the problem here is that our program doesn't work any longer; it can't connect to the computer that's monitoring it. We used "Yet Another Java Service Wrapper" for this, and looked into some other wrappers as well that could help us install it as a service.
Running the program on start up (using the folder startup), but not giving the basic user the privileges to edit/delete/mess around with the files. However, this seems to slow the whole computer down? This doesn't happen when we run the bat file executing the jar directly. Another issue with this is that the user can just go to the task manager and kill the java process.
We tried a variation of the previous one to solve the issue of the process being killed, by having another process. One will spawn the other and these 2 processes will keep tabs on each other. If one terminates, the other detects it and runs it to start it up again. Although it can have issues if the user is fast enough in killing both processes before either is respawned again, the bigger issue is that it sometimes has problems with connecting to other computers. We didn't have this problem when it was just 1 jar.
Does anyone have any idea on how these problems can be solved?
The context here is windows, but if you have suggestions for linux and mac that would be nice too!
Way to go is to run the program as a service. You should investigate any trouble between your application and your system's firewall. If you have windows firewall activated, you should add an exception for java.exe or javaw.exe.
In order to give elevated privileges to your program, you can set the service to run as another user. You can do this from the "Log on" tab in the service properties.
You'll want to have the program started under a user with elevated permissions. On WIndows this would the the Administrator, linux would use root. On Windows, its likely that you will need to start it as a service. But I really don't know why that would hinder the network communications.
Related
I encounter some very strange behavior and I don't know how to handle it.
I suspect that the behavior started to reproduce after last Windows upgrade. But I am not sure if it has anything related to it. (I discovered it when I tried to run maven, which uses java)
The behavior is the following: when run java (e.g. java.exe -version) from command line, it does nothing (like below). The process looks like it is hanged.
enter image description here
I did the following tests:
make a clone of java.exe (e.g. jv.exe) and run it. It works.enter image description here
rename another application to java.exe (e.g. processmonitor.exe to java.exe). When run application, it doesn't open.enter image description here
renamed java.exe to java.exe.bkp and make a link 'java.exe' to 'jv.exe' (which works), and the process is hanged.
make another link java1.exe to jv.exe and it works.enter image description here
did all the operations with&without network, and no difference (java.exe doesn't work, the others work)
restart windows in 'save mode' (+/- network) and java.exe works
I disabled the firewall from windows, and/or I added rules for java.exe. It doesn't work.
Initially I had many JVMs installed. I uninstalled all of them and installed only the one in images. All above tests are made after new installation.
Also, I observed that every time I run java.exe (but not when I run jv.exe or java1.exe) there is a new file java.exe.XXX.dat created in c:\Users\user.name\AppVerifierLogs.enter image description here Searching on google, it seems that is some kind of log file, which can be viewed with this application (https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/application-verifier) but I don't find the standalone application. Maybe it is already installed in the system, but I don't know where or how to enable it.
It seems that for some reason, the Windows is blocking all processes named 'java', no matter if it is actually the java program or any other application. But I'm out of ideas regarding what could be the cause, or how to continue to investigate.
If anyone can help me, I will be grateful to him.
Thank you.
I've inherited and am maintaining a scala/play app that was built several years ago (2014). Every night there's a cron job executing a shell script to restart the app. Running this script from the command line at any time works just fine as well. The app stops, cleans up, rebuilds then restarts.
I've been asked to build a php page which will allow this same shell script to be run via php. I thought it would be very straightforward, but when I exec() the same shell script, I get the output message, ""No java installations was detected."
But of course it is there, where the variables say it should be.
I've tried cd'ing into the directory first before executing the script, and I've tried executing the script as the owner/user of the cpanel account (which is generally how the script is run from the command line). Always the same message. I temporarily tried adding the user to the wheel group (terrible idea long-term I know), but even that didn't work.
I thought it must be some sort of cpanel or server issue, and reached out to the host of the VPS but they didn't think so. The developer of the app is no longer reachable. My guess is it's something he could fix in 5 minutes, I just have no familiarity with this framework.
I've reviewed everything I can online several times and just don't see anything relevant...
Any leads would be greatly appreciated!
I am writing a program in java for an embedded linux platform. One of the OS features I need has to run as root to get access. The platform I am using is the BeagleBone Black and I want to control the Gpio pins using a memory map. I have access to the memory map and can switch the pins on and off at a very fast rate. The problem is, I don't want my program to have to run as super user, at least it doesn't seem right to implement it that way.
Is there a standard technology in linux that will run as root and let a user program make calls to it?
I know there must be, I just don't know what it is. Any help would be appreciated.
What you want to do is to drop privileges. Instead of having any process running as root for the duration, this allows a process to start as root, open resources, and then change to a different, unprivileged user. You'll still need to start the program as root, which can be done with a setuid script so that you don't need the user to be root already to run it. (This is done with other programs, like sudo.)
You can open the file as root, and then change the uid of the program to an unprivileged user (presumably the user that started the program). Take a look at this answer to see how to drop privileges in Java using JNI, and this answer for more information about a robust way to drop privileges in general.
Due to a suite of antivirus and security policies, a java applet I developed for my organization loads very slowly. The problem is not the cache or the applet, but rather it's JVM. When Windows first loads, if I go to command window and enter "java", it will take nearly a minute for the response (the command usage text) to come up. Subsequent commands are responded immediately.
So, one mitigation I can think of is to set all users to run java once as they login. I can either put a shortcut to Start Up folder in the start menu, or create a registry key. If I want this to be as least intrusive as possible (load it in background and in low priority), what's the best way to do this?
Did you consider Windows Task Scheduler and task that starts on windows start-up?
You can add the call to java to the registry, under
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
http://msdn.microsoft.com/en-us/library/aa376977(v=vs.85).aspx
But what about not using java?
I'm developing a scheduling app, it reminds user of things to do during a day, it checks every minute to see if time is up, and if it is it will open an alert window to remind the user. Although it's written in Java, I'm targeting Windows users for this app. It needs to run as soon as users' PCs are turned on, so my question is: How to make a Java app automatically start when a PC is turned on in a Windows system?
I know I can go through a few steps manually to add the app to start-up apps list, but not every user is familiar with the steps, so I wonder if it can do this through my Java program, and if so is there any sample code?
create a .bat file
#javaw -jar path/to/jar/Name.jar arguments
drop this in you startup directory
Use Java Service Wrapper. Set wrapper.ntservice.starttype=DEMAND_START in wrapper configuration.