[Solved] jar file Execute Error: power shell error: unable to access jarfile

 

Problem description

When using the configuration task of vscode, there are problems in executing the jar file, so there are the following solutions.

preparation

Software: vscode
environment: windows10

How to configure

1. Create a task and execute the jar file:

2. Configurable parameters must be placed later

-Dkafka.base.client.bootstrapServers=192.168.75.129:9092

How does it work

1. Run profile location

2. Find the executable file name

More

Building Java code
You can use Maven to perform multiple build lifecycle goals, including compiling project code, creating library packages (such as JAR files), and installing libraries in a local Maven dependency repository
To attempt a build, issue the following command from the command line.
mvn compile

This will run Maven and tell it to perform a compile of the target. When it is done, you should find the compiled .class file in the target/classes directory.
Since you are unlikely to want to distribute or use the .class files directly, you may want to run the package target instead:
mvn package

The package target will compile the Java code, run any tests, and package the code up in the completion target directory via an internal JAR file. the name of the JAR file will be based on the project's <artifactId> and <version>.
For example, given the previous minimal pom.xml file, the JAR file will be named kiwi-0.7.0.jar.

To execute the JAR file, run.
java -jar F:\WorkSoftware\Kafka\kiwi-0.7.0.jar -Dkafka.base.client.bootstrapServers=192.168.75.129:9092

If you change the value of <packaging> "jar" to "war", the result will be a WAR file in the target directory instead of a JAR file.

Read More: