Home > Back-end >  How will run the jar in the environment variable, it can run in any directory
How will run the jar in the environment variable, it can run in any directory

Time:09-19

I wrote a maven project, and then packed into a runnable jar package

I can enter the following command in the CMD, normal operation of the jar


I don't want to enter the absolute path of the jar, now just want to input the Java - jar run. The jar is run the jar package
Could you tell me whether need to put the jar path in the environment variable?
How to configure?

Ps:
1, I don't want to put the jars in the current user C: \ Users \ jiehang, I am hope can be in any path through the Java - jar run. Run the jar
2, I know you can by creating a bat file, in which the specified after the absolute path to the jar, run the bat file directly, but I don't want to do this, I just want to configure the jars to the environment variables,

Excuse me everybody, how to implement?
Please give details, thank you

CodePudding user response:

Put your jar directory PATH this environment variable

CodePudding user response:

Put the jar package address configuration under the classPath?

CodePudding user response:

Directly the jar jrer directory and you put together, and use it every time you direct input. \ jre1.8 x \ bin \ Java jar - XXXX jar

CodePudding user response:

Yes, put the jar package address configuration in the classpath environment variable:
Specific operation is as follows: (a little trouble, upload pictures directly said steps)

First open the file explorer:
Find the "computer", right click choose "properties";
Then click the "advanced system attribute";
Pop-up window, click on the "environment variables";
And then find "CLASSPATH" in "system variables", click;
After a variable's value add jar package path, such as D: \ run jar; Note the front must add a semicolon;
The last point directly determine to go,

CodePudding user response:

Can use the Java jar - D environment variable configuration project. The jar to deploy

CodePudding user response:

reference 4 floor Abel_Liujinquan response:
yes, put the jar package address configuration in the classpath environment variable:
Specific operation is as follows: (a little trouble, upload pictures directly said steps)

First open the file explorer:
Find the "computer", right click choose "properties";
Then click the "advanced system attribute";
Pop-up window, click on the "environment variables";
And then find "CLASSPATH" in "system variables", click;
After a variable's value add jar package path, such as D: \ run jar; Note the front must add a semicolon;
Last point directly determine that

Yes, to set up the classpath, is to realize your aim,

CodePudding user response:

Why I tried on the ClassPath and Path are not?

CodePudding user response:

The
reference 7 floor Meteor Lee reply:
why I tried on the ClassPath and Path are not?


Add file path, the path to add reopened after the completion of the command line

CodePudding user response:

I tried, still won't do

CodePudding user response:

Meteor, 9/f,
quoted Lee reply:
I tried, still won't do


Post your Settings

CodePudding user response:

And you execute the command line, and an error content, ask questions to clarify situation,

CodePudding user response:

Sorry, made a relatively low-level mistakes, I in the environment variable configuration for two JDK, found the problem, has been solved

CodePudding user response:

Don't need to put the directory with the jar in the environment variable, because you can't ensure that the next time you will be in the same directory, run the jar, of course if you're going to have long in the directory, run the jar that also can, you can be in command line CD that directory, then run the Java jar - *. The jar

CodePudding user response:

Into the classpath is running can be executed directly or refer to the corresponding class, run the bat is a Java implementation class name, rather than Java - jar xx. The jar

CodePudding user response:

Put the jar package path in the path environment variable line, specific methods for Google,
  • Related