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.
Related
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.
I am trying to install maven v3.5.4 onto my computer and whenever I try the 'mvn -version' command, I get
'mvn' is not recognized as an internal or external command,
operable program or batch file.
I have looked up multiple tutorials on how to do this, and they are giving nearly the same information. Add system variables M2 and M2_HOME, then append a directory to the Path system variable. I have the System Variables configured to the following:
M2:
Name: M2
Value: C:\Program Files\Apache\maven\bin
M2_HOME:
Name: M2_HOME
Value: C:\Program Files\Apache\maven
MAVEN_HOME:
Name: MAVEN_HOME
Value: C:\Program Files\Apache\maven
Path:
Name: Path
Value: %M2_HOME%\bin;%JAVA_HOME%\bin
I have seen people saying that there should be a .exe or .bat file inside the bin directory. I do not have any of these. I only have 4 files inside this folder.
This could perhaps be the issue. The path to my Maven directory is:
I have the following maven related system variables:
And my Path variable is:
I'm not sure how to fix this issue so if anyone knows, please let me know.
Add a variable MAVEN_HOME like:
Name: MAVEN_HOME
Value: C:\Program Files\apache-maven-3.3.9\bin
In your case, the M2_HOME path is not correct. Hence It must not be working. Try to give the correct path to the bin folder.
First you have to download maven from here, preferably the latest version and install it.
Then, you have to set the Path variable for Maven.
Go to Start and search for 'Edit the system environment variables'.
Choose the environment variables option and like you do in the example you provided, leave M2_HOME as you have it, delete M2 and change the one in your path to: %M2_HOME%\bin\;
Also, please make sure that you are editing the system environment variables.
As I it says on the download page of the version you are trying to install: "Maven 3.3+ require JDK 1.7 or above to execute". So make sure you have the right version of java.
If this does not work, then I don't think someone on Stack-Overflow can help.
Install Java
Download Java SE Development Kit from Oracle's website and install it
Browse via windows search to Environment Variables
Press New... in System variables list
Insert JAVA_HOME to Variable name
Insert its path to Variable value (e.g: C:\Program Files\Java\jdk1.8.0_102)
Press Edit to Path and then press New
Insert %JAVA_HOME%\bin
Open cmd and type java -version to check if it is ok
Install Maven
Download Maven Binary zip archive from Apaches's website
Unzip the folder and move it to C:\Program Files
Browse via windows search to Environment Variables
Press New... in System variables list
Insert MAVEN_HOME to Variable name
Insert its path to Variable value (e.g: C:\Program Files\apache-maven-3.6.2)
Press Edit to Path and then press New
Insert %MAVEN_HOME%\bin
Open cmd and type mvn -version to check if it is ok
Is there a way to build an RCP application an relocate the eclipse.ini in a different location from where the eclipse.exe is located?
The Eclipse Product wizard only provides a "Root directory" where all files are exported to. It seems eclipse.exe has something built into it to look in the same directory for the ini parameters.
You can override where Eclipse looks for the eclipse.ini using the --launcher.ini command line argument to eclipse.
So if you do:
/path/to/eclipse -data /path/to/workspace
then it will use /path/to/eclipse.ini (on linux/win) and /path/Eclipse/eclipse.ini (on osx), if you want it to read a different file, do this:
/path/to/eclipse --launcher.ini /anotherpath/to/eclipse.ini -data /path/to/workspace
will cause eclipse to read /anotherpath/to/eclipse.ini instead of the default.
See Eclipse Help on the launcher command line arguments.
I'm using Maven and IzPack. I'm looking for a way to put a file into the directory of the installer file. In the install.xml I've got a file tag set with a targetdir of "." but that will only work if the installer is executed from that directory. If executed from a different directory, the file is put in the current working directory of the user instead.
Having checked IzPack documentation, there's a built-in variable for $INSTALL_PATH, but I need the path of the installer. There's no way to predict where this installer will be when executed so specifying a pre-set directory won't work. Trying to specify the local directory via Maven just gives the path to the POM.
Is there an undocumented variable that would do the job or something else I've overlooked?
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?