使用命令行工具列出当前类路径中的可用类 [英] Listing available classes in current classpath using a command line tool

查看:71
本文介绍了使用命令行工具列出当前类路径中的可用类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用默认的JRE / JDK命令行工具检查当前目录中是否有特定的类。

I need to check if a specific class is available from current directory using a default JRE/JDK command line tool.

我可以构建自己的类来列出它,或者检查当前目录和当前CLASSPATH环境变量中某个特定的类是否可达,但是该选项不可用,因为我需要检查特定的类名在受保护的生产环境中是否可用(只读)。

I could build my own class to list it or check if a specific class is reacheble from current directory and current CLASSPATH environment variable, but this option is not available since I need to check if a specific class name is available or not in a protected production environment (read only).

推荐答案

您可以使用 javap

$ javap java.lang.String
Compiled from "String.java"
public final class java.lang.String implements java.io.Serializable
[...]


$ javap no.such.Class
Error:  class not found: no.such.Class

这篇关于使用命令行工具列出当前类路径中的可用类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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