文件系统中的哪里是我的Java类加载? [英] Where on the file system was my Java class loaded from?

查看:106
本文介绍了文件系统中的哪里是我的Java类加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为这是每个Java程序员遇到的情况,如果他们做得足够长时间。你正在做一些调试,并改变上课。当您重新运行程序时,这些更改似乎并没有被拾起,而是旧的类似乎仍在运行。你清理和重建一切,同样的问题。有时,这可能会降到类路径问题,同一类在类路径上不止一次,但似乎没有一个简单的方法来确定加载的类是从哪里来的...



有没有办法找到加载的类的文件路径?如果该类是从 .class 文件或 .jar 文件加载的,则可以使用它。任何想法?

解决方案

使用标准命令行开关运行 java -verbose:class (见 java 文档)。这将在每次加载课程时打印出来,并告诉您从哪里加载课程。


I think this is a situation every Java programmer runs into if they do it long enough. You're doing some debugging and make a change to class. When you go to re-run the program, these changes don't seem to be picked up but rather the old class still seems to be running. You clean and rebuild everything, same issue. Sometimes, this can come down to a classpath issue, of the same class being on the classpath more than once, but there doesn't seem to be an easy way to figure out where the class being loaded is coming from...

Is there any way to find the file path for the class that was loaded? Preferable something that would work either if the class was loaded from a .class file or a .jar file. Any Ideas?

解决方案

Simply run java using the standard command line switch"-verbose:class" (see the java documentation). This will print out each time a class is loaded and tell you where it's loaded from.

这篇关于文件系统中的哪里是我的Java类加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆