Java.Lang.IllegalAccessError 升级到新计算机后所有程序

Java.Lang.IllegalAccessError on all programs after upgrading to a new computer

我昨天买了一台新电脑 (Dell XPS 13)。我刚刚安装了 JDK 并将我所有的旧 Java 项目复制到我的新设备上,但是当我尝试 运行 这些程序中的任何一个时,我遇到了非法访问错误。

编辑:注意:升级前我使用的是jdk1.8.0_151。我现在使用 jdk-12.0.2。

我已经尝试重新编译某些项目中的所有 classes,但这没有帮助。请注意,非法访问错误仅在运行时出现。我看过其他关于非法访问错误的 Whosebug 帖子,但是 none 他们的解决方案对我有用。

    Exception in thread "main" java.lang.IllegalAccessError: failed to access class Tree from class BinTree (Tree is in unnamed module of loader 'app'; BinTree is in unnamed module of loader com.sun.tools.javac.launcher.Main$MemoryClassLoader @48a242ce)
    at BinTree.main(BinTree.Java:12)

编辑:该项目的项目层次结构是:

    BinTree:
        Tree:
            Node

编辑:这是项目的主要class:

    import java.util.Scanner;
    import java.util.ArrayList;
    class BinTree {
        public static void main(String[] args) {
            //Create randomized values for a new tree 
            ArrayList<Double> toSort = new ArrayList<Double>();
            for (int i = 1; i <= 1300; i++) {
                double rand = 1 + ((int)(Math.random()*100000));
                toSort.add(rand);
            }
            //Create tree
            Tree binTree = new Tree(toSort);
            binTree.getGreatestNode();
            binTree.sort();
        }
    }

尝试一次编译项目的所有 .java 源文件。如果您在同一目录中拥有所有三个文件 BinTreeTreeNode,那么您可以使用 cmd/terminal 轻松转到该目录并写入:

javac *.java

它应该一次编译该目录下的所有 java 文件。