Get the App
SLTechnology News&Howtos  ›  Development  › 

How to solve the classpath problem of Java

Shulou Source: shulou.com Published: 2022-06-03 01:39:52 10月02日 Update

This article mainly explains "how to solve the classpath problem of Java". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to solve the classpath problem of Java".

When running Java programs, it is often necessary to specify a directory containing various jar packages as the classpath. We used to use-Djava.ext.dirs=... To specify the jar directory.

But in the new version of JDK, which seems to start with JDK 9, you will be prompted when you still use this parameter:

C:\ Users\ Winter Lau > java-Djava.ext.dirs=lib-Djava.ext.dirs=lib is not supported. Use-classpath instead.Error: Could not create the Java Virtual Machine.Error: A fatal exception has occurred. Program will exit.

Well, it's easy for you to replace it with-classpath or-cp.

And then I'll try.

Java-cp lib xxx.xxxxjava-cp lib\ * .jar xxx.xxx

Although the result is correct, the classpath setting does not work.

After thinking about it for a long time, I can't believe I want to play like this:

Java-cp lib\ * xxx.xxxx

Note that it's lib\ * instead of lib\ *. Jar is not lib. Linux can be replaced with a forward slash.

Thank you for your reading, the above is the content of "how to solve the classpath problem of Java". After the study of this article, I believe you have a deeper understanding of how to solve the classpath problem of Java. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Paths problems learning content directories convenience functions parameters that is ideas situations articles slashes time more knowledge knowledge points programs articles results Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology macOS OPPO Reno Shulou Information Huawei