1 year ago
#384317

Van Jake
Command line with multiple libraries
I am trying to run my java class by command line. When I executed throw an error:
PS C:\Users\mcruz\Desktop\diff-java> javac src/main/Main.java
src\main\Main.java:8: error: package com.google.gson does not exist
import com.google.gson.Gson;
^
src\main\Main.java:10: error: package object does not exist
import object.Command;
^
src\main\Main.java:11: error: package object does not exist
import object.Environments;
^
src\main\Main.java:12: error: package object does not exist
import object.MetadataType;
^
src\main\Main.java:13: error: package object does not exist
import object.PackageBuild;
^
src\main\Main.java:14: error: package object does not exist
import object.ReadFile;
^
src\main\Main.java:16: error: package object does not exist
import object.Resource;
I don't know if this command detects the libraries that I implement in the project or what I need to do to solve this problem. (My libraries are in a folder with the name lib.)
I read in another post that I can use javac -cp to add the classpath but, I need to add more than one library.
Example :
javac -cp lib/error_prone_annotations-2.11.0.jar;lib/gson-2.9.0.jar;lib/logger-1.24.0.jar;lib/logger-slf4j-1.24.0.jar;lib/logger-spi-1.24.0.jar;lib7safe-logging-1.24.0.jar;lib/slf4j-api-1.7.31.jar src/main/Main.java
package main;
import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
import com.google.gson.Gson;
import object.Command;
import object.Environments;
import object.MetadataType;
import object.PackageBuild;
import object.ReadFile;
import object.Resource;
public class Main { ........
java
command
0 Answers
Your Answer