Execute a jar from a custom URL protocol - windows

I successfully created a custom URL protocol in Windows following this instructions that targets a simple jar that I created, I can run this jar manually by executing this command (java is in the PATH):
java -jar test.jar
But when I open an URL that uses my custom protocol, it doesn't execute the jar, the protocol is supposed to execute the same command, this is how it looks in the Registry Editor:
"C:\Program Files\Java\jdk1.8.0_152\bin\java.exe -jar C:\testFolder\test.jar" "%1"
If I replace the jar with an .exe file it works fine, for example notepad.exe or the calculator, so the problem is executing the jar.

"C:\Program Files\Java\jre1.8.0_202\bin\java.exe" "-jar" "C:\Users\user\Desktop\DisplayStartArgumentsInFrame.jar" "%1"
Is the required command in the registry entry. I was also trying around with url protocols and had the same problem. I don't know why, but it works.
Edit: use javaw.exe instead of java.exe to suppress the terminal.

Related

I tried to use maven in cmd, but I don't get the generated .jar file in the specified location

I used mvn clean package -DoutputDirectory=<my path>, but I don't get compiled .jar file in my listed output directory via command prompt, does anyone knows, how to fix it in the cmd?
Here's my debug configuration from Intellij IDEA Community:
https://i.imgur.com/KDnLYDV.png

can't access jenkins configuration file dir

I would like to know why, after running on my console:
java -jar jenkins.war
and going after the installation process, I can't access the jenkins configuration dir in the same dir as the war file. Where should I look this dir in case I wanna backup ?.
Default location for Jenkins on a Windows machine is C:\Users\<USERNAME>\.jenkins. You can specify this location by specifying JENKINS_HOME, like this:
java -DJENKINS_HOME=C:\path\to\jenkins\home -jar jenkins.war

Apache Maven is not configured properly into System vairable

I have latest version of Apache Maven 3.3.9 residing in my drive downloaded from here. I need it for configuring Appium tool to perform automated testing of Android applications. I have Maven plugin already configured with my Eclipse IDE. I went through few articles and got to know that I have to configure Maven into system variables as well. I set system variables, path for it as below.
M2HOME = C:\Program Files (x86)\Apache\apache-maven-3.3.9
M2 = %M2HOME%\bin
path = C:\Program Files\Java\jdk1.8.0_31\bin;%M2%
I tried running mvn , mvn -version from cmd prompt to check successful configuration of Maven but it gave me nothing. I tried navigating to the bin folder and re run the command but still the result is same. I even changed my path variable to have absolute path of Apache Maven i.e path = C:\Program Files (x86)\Apache\apache-maven-3.3.9\bin
To be further sure I copied the Apache Maven to a different folder just because it had spaces in between Program Files and Program Files (x86) but still the command prompt is as below:
I had followed above steps referring various articles in google. I'm not getting if I have committed any unseen mistake.
P.S: I have even tried above commands with cmd running as an administrator
Try mvn --version (with two dashes). mvn -v should also work. If Maven is not being executed at all, I suggest you try mvn.bat.
Some Command Prompt configurations will refuse to run .bat-files without the extension unless you explicitly tell them to.
It's probably a good idea to run where mvn in your Command Prompt as well. You should get this:
<YOUR_MAVEN_HOME>\bin\mvn
<YOUR_MAVEN_HOME>\bin\mvn.bat
<YOUR_MAVEN_HOME>\bin\mvn.cmd
if everything it set up correctly.
You should define M2_HOME variable. (Not M2HOME). Make sure it looks like this:
You said that you copied your maven to the location without spaces. That's a good idea. But it looks like your Path system variable points to the old location of maven. Make sure to change it. (What is the current location of maven?)
BTW mvn -version works as well as mvn --version

Open jar file with cmd

I have a jar file named "adventure.jar". When you run it through the cmd with java -jar adventure.jar it works fine. However, I am testing opening the file on a new computer, and I am encountering a problem. This computer doesn't have the java command in the command prompt. It defiantly has Java installed, but maybe just not the JDK? Anyway, my goal is to make the jar file run from cmd when double clicked, without the need of commands (is that even possible?). The jar is already executable, but it doesn't execute from the command prompt like I need. Any help would be appreciated.
EDIT: If there is a way to do this through an exe or batch file I'd be fine with that, too.
Sounds like your PATH env. variable doesn't have Java in it. You can add it by following Oracle's tutorial
Adding Java to your PATH Environment variable.
Usually it's something like ;C:\Program Files\Java\jre7\bin
To your second question - yes it's possible.
Open up notepad, then type java -jar adventure.jar then save it as launch.bat or something. then you are able to double click that batch file, which will run your java archive.
Open command prompt
Go to the folde where jar file is located
Run
unzip test.jar
here test.jar is name of the jar file.
This command will unzip all the file into that folder
First, try start adventure.jar from Command Prompt. If that does not work, locate java.exe (on my computer, C:\Program Files\Java\jre7\bin) and either use the full path in Command Prompt, or add the path to the folder containing java.exe to your PATH environment variable. To add the path, click Start Menu, right-click Computer, click Properties, click Advanced System Settings, click Environment Variables, then find PATH under System Variables and click Edit, and add the path (example: add the following onto the end of PATH: ;C:\Program Files\Java\jre7\bin and don't forget the semicolon!)
Hope it helps.

How to make the yuicompressor jar file a singleton, or globally accessible?

I'd like to put the yuicompressor jar file in a single folder so that I can call
java -jar yuicompressor-2.4.2.jar ...
from anywhere on my system, with cygwin. For bash files I use I simply put them in a common folder, and added the folder's path to my windows user's PATH environment variable and the bash commands were found in cygwin.
when I echo $PATH I see the folder I put the yuicompressor jar into listed in the $PATH..
But when I try java -jar yuicompressor-x.y.z.jar myfile.js -o myfile-min.js (for example) I get the following error message:
Unable to access jarfile yuicompressor-2.4.2.jar
Even when I try providing an absolute path to the jarfile I get the same error message..
How can I do this?
The PATH environment variable is a list of directories the shell will search through in an attempt to run a command.
java.exe will not search the directories on the PATH environment variable to try and locate the archive you are attempting to run. So running java -jar yuicompressor-2.4.2.jar from any directory other than the one containing the archive would be expected to fail.
What is the full command you are attempting when providing an absolute path?

Resources