I am trying to launch a jar file on Windows Server 2008 R2 startup.
I tried to add a key\value to
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
I tried as a value several alternatives:
java -jar c:\jcm\jcm.jar
"java -jar c:\jcm\jcm.jar"
c:\program files(x86)\java\jre1.8.31\bin\java.exe -jar c:\jcm\jcm.jar
"c:\program files(x86)\java\jre1.8.31\bin\java.exe -jar c:\jcm\jcm.jar"
"c:\program files(x86)\java\jre1.8.31\bin\java.exe" -jar c:\jcm\jcm.jar
But none of them launched the program.
Can you advise please?
EDIT: Fixed exe to jar of course
You probably have a problem in the command line. I think it should be something like that last row that you have used but with jar and not exe.
"c:\program files(x86)\java\jre1.8.31\bin\java.exe" -jar c:\jcm\jcm.jar
You just need to test it in command line first and if it works it will work in the registry. You can also make a .bat file to start the java program and copy that to windows Startup Folder instead of using the registry.
The startup folder you can find here:
http://windows.microsoft.com/en-us/windows/run-program-automatically-windows-starts#1TC=windows-7
If it is Windows 10 then you may try this way-
Create a batch file e.g. (my-batch.bat with below statements.)
#echo off
title my-app batch script!
echo my-app welcomes you!
:: If your JAR contains GUI then use-
start javaw -Xmx200m -jar D:\Softwares\JAR\my-app-v1.0.jar
:: Otherwise use-
start java -jar D:\Softwares\JAR\my-app-v1.0.jar
Copy this my-batch.bat file at
C:\Users\pc\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
Restart your PC to execute your JAR on startup.
Now, You may check your running JAR using Command Prompt with below commands-
1. jps -l
Output will look like-
8120 sun.tools.jps.Jps
13276 D:\Softwares\JAR\my-app-v1.0.jar
2. tasklist /V
Related
I am using following working command for Windows batch file.
set projectLocation=E:\APPIUM\CXMFunctionalTest\LinuxAPITest
cd %projectLocation%
set classpath=%projectLocation%\bin;%projectLocation%\lib\*
java org.testng.TestNG %projectLocation%\testng.xml
pause
How i can convert this into Linux Shell Script? So i can run it in Linux machine.
cd /home/[[youruser]]/APPIUM;
java org.testng.TestNG /home/[[youruser]]/APPIUM/testng.xml;
This should be sufficient, considering that [[youruser]] is your users home folder, and the APPIUM folder is placed directly inside it. Then you can put this in a file called runappium.sh, and run it with the command sh appium.sh or mark it executable and run it directly.
I downloaded SymmetricDS, a tool for Database replication and tried to run it on my Windows7 machine. The program can be launched from command line and it works with Windows Terminal. However I always prefer Git Bash for command line stuff. When I run command sym though, I got error:
Error: Could not find or load main class org.jumpmind.symmetric.SymmetricLauncher
This tool is written in Java. I have JDK 1.8 installed. Git Bash inherits all environmental variables including $PATH and $JAVA_HOME from Windows. But why is it complaining about not finding the class?
The sym command is really running the following command:
exec "$SYM_JAVA" $SYM_OPTIONS -cp "$CLASSPATH" org.jumpmind.symmetric.SymmetricLauncher "$#"
All the jars are located in lib under the root directory of the application. The classpath is defined in a sym.service.conf inside conf directory:
# Java Classpath
wrapper.java.classpath.1=patches
wrapper.java.classpath.2=patches/*
wrapper.java.classpath.3=lib/*.jar
wrapper.java.classpath.4=web/WEB-INF/lib/*.jar
# Application main class and arguments
wrapper.app.parameter.1=org.jumpmind.symmetric.SymmetricLauncher
I added echo $CLASSPATH right before the exec to print out the class path and it did seem to get all of them right:
/c/Users/dnj0109/Apps/symmetric-server-3.8.29/patches:
/c/Users/dnj0109/Apps/symmetric-server-3.8.29/patches/*:
/c/Users/dnj0109/Apps/symmetric-server-3.8.29/lib/*:
/c/Users/dnj0109/Apps/symmetric-server-3.8.29/web/WEB-INF/lib/*
That could be related to this thread:
On Windows, the path separator is a semicolon (';' instead of ':').
Don't ask why. Traditionally, the semicolon is interpreted by the Bash as
the command separator, so you'll have to escape it:
$ java -cp lib/clojure-1.1.0.jar\;lib/clojure-contrib-1.1.0.jar
If you wonder why it works with PATH: MSys has special handling routines
for that.
Another reason that a java app may run in a Windows CMD shell but not in a Windows git bash shell is that the classpath used to run the app contains one of the following:
relative paths (e.g. ../foo)
network drives (e.g. //servername/bah
See:
https://github.com/git-for-windows/git/issues/1028
I have 3 files :
MyApp.jar
start.cmd
start.sh
Here is what's in the start files :
java -cp MyApp.jar -Xms256m -Xmx1024m com.companyname.launch.Launcher someArgs -DsomeParameter=true
As you can guess, I have to start the application by executing the correct start file, depending on the OS I'm using.
Is there a simple solution to get rid of the start files, and have only a system independent executable jar file ?
You can run this from Java.
Have a FirstMain which doesn't depend on anything. e.g. can be run without command line arguments. This main start another java program for the same JAR starting the RealMain with all the command line arguments you need.
I created a simple batch file to run jar server file. It is two lines of code:
cd /D %~dp0
java -jar server-0.17.0.jar
The problem is the server file is updated every while and hence script either fails to run the correct version or fail to run.
My request is, is there anyway to replace server jar file with latest released by number or date dynamically?
I'm only aware that I can retrieve available jar files using:
dir *.jar
But have no idea how to concatenate the command with the katest version. Thanks
you can try a script like this:
#echo off
for /f "delims=" %%x in ('dir /od /b server*.jar') do set latestjar=%%x
java -jar %latestjar%
Second line in this script will set the latestjar to the last created file whose name compliant with server*.jar template.
I'm using Java EE with Glassfish.
I can't run asadmin command as well. I did the following, but output from terminal is:
No command 'asadmin' found, did you mean: Command 'amadmin' from package 'amanda-server' (universe) Command 'acsadmin' from package'ion' (universe) asadmin: command not found
I have Ubuntu 14.04 Trusty Tahr. I should be in bin directory of glassfish, so I'm in /opt/glassfish4/bin.
But always nothing happend, just error message above.
In Ubuntu and Linux in generĂ¡l, you run commands from current directory like this: ./asadmin, ie. you must prepend ./ to make it explicit that you run a command I current directory. This is traditionally for some security reasons.
Try following command export PATH=/installationDirectory/glassfishName/bin:$PATH
In my case it was export PATH=/opt/glassfish4/bin:$PATH
The asadmin command needs to be read from glassfish bin directory when executing commands, hence you need to export the following in your environment variables.
On mac,
export PATH=/Users/macpro15/Downloads/glassfish5/bin:$PATH
I think you are creating the domain inside the default domain. You should make your own domain in the domains folder, and the run the following command in your terminal:
sh asadmin start-domain DOMAIN_NAME