Is anyone having a problem running a Windows Service with JavaExe, and is there a solution?
The JavaExe examples all work except for the Service examples, Example3, Example5, and Example23.
In each case, the Windows Service gets created, but any attempt to start the service brings a popup error message:
"The system cannot find the file specified."
There is a registry entry for the serivce which contains the following:
Name: ImagePath
Type: REG_EXPAND_SZ
Data: "\JavaExe\JavaExe\doc\examples\3 - Service\Example3.exe" __RunService__
If I run Example3.exe from a command line with the argument __RunService__, then a Java process starts and runs briefly before crashing.
The examples are all self-contained in the JavaExe download, so it's hard to see how there could be missing libraries.
Background: JavaExe (http://devwizard.free.fr/html/en/JavaExe.html) appears to implement a sound approach to allowing a Java application program to be invoked from another Java program running as a service. Windows prevents services from accessing the desktop, so JavaExe sets up a socket connection between the service and the application Java program, each running as a User process, as outlined here:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms683502(v=vs.85).aspx
Windows 7 x64 (but it fails in the same way on XP [SEE UPDATE BELOW])
Java version 1.7.0_45
--
UPDATE:
The developer replied to my email and advised that 32-bit and 64-bit Java versions were being confused.
I straightened this out. The Example3 Service, run from the .exe and .jar files obtained from the
JavaExe .zip download (which are all 32 bit by default), now run correctly on WinXP (x86).
For x64 machines, it is necessary to recompile the jar files using the package's compilx64.bat script.
(And to use the x64 versions of JaveExe.exe as stated in the documentation.)
I did these things but the Example3 service still fails to start, with the error,
"The system cannot find the file specified."
The .jar files built from compilx64.bat are mostly identical to the x86 versions, but a few
contain .class files that are a few bytes larger. I assume that the code must therefore be referring to native libraries? And maybe some are not found? But which ones?
When I type sc qc Example3 I get:
TYPE: : 10 WIN32_OWN_PROCESS
START_TYPE: 2 AUTO_START
ERROR_CONTROL: 1 NORMAL
BINARY_PATH_NAME : "[...filepath...]\JavaExe\JavaExe\doc\examples\3 - Service\Example3.exe" __RunService__
LOAD_ORDER_GROUP: 0
DISPLAY_NAME: JavaExe : Example3
DEPENDENCIES: eventlog
SERVICE_START_NAME: LocalSystem
Answer:
The filepath to the Example3.exe was on a network drive.
To get a Windows Service to run from a network drive is either impossible or requires considerable contortions. See for example,
Map a network drive to be used by a service
When I moved everything to the local C: drive, it worked.
Thank you to bb67 for providing the hints that led to figuring this out.
Related
I have an application (written about 10 years ago by someone else who is retired) that resides on a Stand-Alone Windows XP PC.
It was devleoped using NetBeans (Currently we have 6.9 installed on the PC) and controls a testbench for running component testing.
The application, initiated by a batch file on the desktop, has functioned perfectly well for Approximately 10 years.
However, 2 days ago it just stopped working with a message
'File Not Found' with the correct path and filename to a Config File that resides in a directory on the PC. This file exists.
I tried to run the application from the Dos command line (in the DIST ribution directory) using
Java -jar “AdBlue.jar”
This resulted in an error message being returned
'Exception In Thread "main" java.lang.UnsupportedClassVersionError ..... Could Not Find The Main Class"
No changes have been made to the PC.
It is the same Operating system (Windows XP - Shortly To Be Upgraded)
The java version has not been changed
The application has not been changed
The config file is still in the same directory
The permissions on the Config file have not been changed
I have checked Properties/Run and 'AdBlue.Main' is selected.
I am at a loss.
I would appreciate it if someone could point me (Someone who has not used java and Netbeans before) in the right direction. The test bench has come to a stand still and it will affect out production line shortly
We have found that teh file being searched for is corrupt.
It has been recreated and appears to have solved the problem
Thanks for all of the replies
Kind regards
Iain
I'm trying to get started with LWJGL 3, but it doesn't even run the sample program. It just crashes the JVM (error code 134, SIGABRT, JVM tries to access memory at address 0).
I've reinstalled Gradle, made sure it uses the right Java version and re-downloaded the LWJGL script, but to no avail.
EDIT: I updated Java to the latest version, but it still doesn't work...
I used the default Java app Gradle config and the sample program (linked above).
The expected behaviour is the app running, opening a window, etc., but instead Java crashes.
Execution failed for task ':run'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home/bin/java'' finished with non-zero exit value 134
The sample program uses GWT (Java GUI - graphic interface). It requires xorg server running on Linux (if you are on Linux). See the answer JVM error: Process finished with exit code 134 (interrupted by signal 6: SIGABRT)
I have had this same issue (exit value 134) before, but maybe in a slightly different context: in Android Studio running on a Ubuntu machine. When this happened, I also saw an error log file produced under the ./app folder, named “hs_err_pid[a number].log”. This log file provided more info about the error. However, I still couldn’t figure out a solution by reading the log file.
Since this error does not always happen to me, I’ve tried 2 brute-force methods:
Method #1. Remove the ./build folder
Method #2. In Android Studio, → File → Invalidate Cashes / Restart…
It appears that the error can be avoided by using one of, or a combination of, these 2 methods.
Not sure if its relevant but I faced the same issue while trying to run some introductory code on my Mac. For me the issue seemed to be around library version configurations. I was earlier using these:
project.ext.lwjglVersion = "3.2.3"
project.ext.jomlVersion = "1.10.4"
And later changed it to this (As per the LWJGL library customisation page)
project.ext.lwjglVersion = "3.3.1"
project.ext.jomlVersion = "1.10.4"
Further, I also added the VM option: -XstartOnFirstThread
But that was for a different error only as far as I understand.
I downloaded the Carrot2 Document clustering server build 3.15.0 for Mac. The read me file says:
The DCS requires a Java Runtime Environment (JRE) version 1.7.0 or later. To
run the DCS, execute the 'dcs' script and point your browser at
http://localhost:8080 for further instructions.
Mac OS Sierra doesn't make it easy, but I got 1.8.0_112 installed.
The problem is that I don't know how to execute the 'dcs' script.
There are .cmd, .sh, .war, and .jar files. I wasn't sure which of those to work with. I thought .jar looked promising, so I followed some of this thread and tried this in a terminal window:
java -jar invoker.jar
I cd-ed to the correct directory, but it just says Provide main class, but I'm not sure what or where that is.
Can anybody provide instructions or a link to how to do this?
Use the dcs.sh (on Linux/Mac) and dcs.cmd (on Windows) to start the server. The scripts will set some extra options for the JVM and then start the DCS. In case of any problems, append the -v option to see diagnostic output.
I have a program in java I run through a service I wrote who uses JNI to start a JVM and launch the program. The program dynamically loads other jni dlls when it needs to.
The problem is that if i run the service as NetworkService, the jni dlls load fine, but if i run it as a LocalService (which has more privileges and should be able to access the network) I get a java.lang.UnsatisfiedLinkError: C:\Netstar\build_0704_24_02\lib\JobExecutable.dll: The specified procedure could not be found
Some more details:
I run the service from a windows share, but before it runs java it copies all the jars and dlls locally. I tried using dependancy walker but it led me nowhere. I also made sure there are no network paths in my Path environment variable. One of the java directives is -Djava.library.path=C:\Netstar\build_0704_24_02\lib
Thanks for the help
I know this question has been asked/answered several times, but I still couldn't find a solution to this ClassNotFoundException error, because it works on my computer but not on my RasPi (on which I installed OpenJDK7).
My application uses JDBC to access a MySQL database, and that's the main problem. As has been pointed out on lots of websites ([1], [2], [3]), this is, unfortunately, a common problem.
So, I'm using the mysql-connector-java-5.0.8.jar as a driver. My folder structure is something like /src/de/web/project/ I'm calling the main method via java de.web.project.WakeOnLan (which is the main class that starts all other classes etc.) I got the common ClassNotFound exception and therefor added the -cp parameter so I called the project via java -cp .;mysql-connector-java-5.0.8.jar de.web.project.WakeOnLan to add the driver to classpath.
This worked nicely on my Windows computer from command line, but now I want to push this code to my Raspberry Pi and execute it there. As I said, I installed OpenJDK7 there (using apt-get, if this should be important), used SFTP to upload the folder structure and the code to /home/pi/java/ where there is also the ejre1.7.0_10 folder (so the code is now actually in /home/pi/java/de/web/project/).
I now went back to /home/pi/java and entered java -cp .;mysql-connector-java-5.0.8.jar de.web.project.WakeOnLan as I did on my Windows computer, but it refuses to work (I've put the connector in any folder on the way, just in case). When I call this function, I get a long list of hints Java wants to give me which parameters are allowed for java, finally stating: -bash: mysql-connector-java-5.0.8.jar: command not found. I also tried to turn ".;mysql..." around to "mysql...;." which didn't work as well. If I don't include the -cp parameter, my program says "Thread started" and in the next line: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver etc., so the program does indeed start and writes "Thread started" to System.out.
For some reason, it looks like Java on the Pi ignored the second value of the classpath parameter for which I don't see a good reason.
You might just have problem in classpath setting, there is difference for windows and linux
The classpath syntax is OS-dependent. From Wikipedia :
Being closely associated with the file system, the command-line
Classpath syntax depends on the operating system. For example:
on all Unix-like operating systems (such as Linux and Mac OS X), the
directory structure has a Unix syntax, with separate file paths
separated by a colon (":").
on Windows, the directory structure has a Windows syntax, and each
file path must be separated by a semicolon (";").
This does not apply when the Classpath is defined in manifest files,
where each file path must be separated by a space (" "), regardless of
the operating system.