在命令提示符下运行Java程序时“程序包edu.princeton.cs.algs4不存在”

问题描述

我正在研究算法,并使用此站点来学习:https://algs4.cs.princeton.edu/

目前还使用其库来运行示例代码

algs4.jar

我在NetBeans IDE中的认包下创建一个名为UFClient的类: image

UFClient的代码

 /*
 * To change this license header,choose License Headers in Project Properties.
 * To change this template file,choose Tools | Templates
 * and open the template in the editor.
 */
package dsasample;
import edu.princeton.cs.algs4.*;
/**
 *
 * @author Dell
 */
public class UFClient {
    public static void main(String[] args)
 {
    int N = StdIn.readInt();
    UF uf = new UF(N);
    while (!StdIn.isEmpty())
    {
        int p = StdIn.readInt();
        int q = StdIn.readInt();
        if (!uf.connected(p,q))
        {
            uf.union(p,q);
            StdOut.println(p + " " + q);
        }
     }
    }
}

我使用以下命令在命令提示符下执行:

javac -cp D:\ coursera \ algs-4.jar;。 UFClient.java

但是这个错误

D:\Netbean_Proj\DSASample\src\dsasample>javac -cp D:\coursera\algs-4.jar;. UFClient.java
UFClient.java:7: error: package edu.princeton.cs.algs4 does not exist
import edu.princeton.cs.algs4.*;
^
UFClient.java:15: error: cannot find symbol
    int N = StdIn.readInt();
            ^
  symbol:   variable StdIn
  location: class UFClient
UFClient.java:16: error: cannot find symbol
    UF uf = new UF(N);
    ^
  symbol:   class UF
  location: class UFClient
UFClient.java:16: error: cannot find symbol
    UF uf = new UF(N);
                ^
  symbol:   class UF
  location: class UFClient
UFClient.java:17: error: cannot find symbol
    while (!StdIn.isEmpty())
            ^
  symbol:   variable StdIn
  location: class UFClient
UFClient.java:19: error: cannot find symbol
        int p = StdIn.readInt();
                ^
  symbol:   variable StdIn
  location: class UFClient
UFClient.java:20: error: cannot find symbol
        int q = StdIn.readInt();
                ^
  symbol:   variable StdIn
  location: class UFClient
UFClient.java:24: error: cannot find symbol
            StdOut.println(p + " " + q);
            ^
  symbol:   variable StdOut
  location: class UFClient
8 errors

D:\Netbean_Proj\DSASample\src\dsasample>

怎么了?如何解决

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)