Java, how to search if a class exists with a Jar

What is the comand to determine if a class exists within a jar

I tried the following

java -jar TEST.jar -i . button
Ignoring unknown flag: -i
Ignoring unknown flag: .
Ignoring unknown flag: button


Open in new window

But obviously it did not work

Could someone please post an example of how to do this for

1> Th ecurrent directory

2> any subdirectory

Los Angeles1Asked:
Who is Participating?
CEHJConnect With a Mentor Commented:
Simply go to your JDK bin path

If you're doing anything with Java other than running apps, you should

a. You need a JDK
b. Its bin directory should be in PATH
 i've already given you. If you want to use the command line (assuming Windows)

jar tf x.jar | find "something"

Open in new window

Of course, that will only work for one jar at a time
Los Angeles1Author Commented:
I dont have an excutable named jar

Do you mean java

I can not get tf or -tf to work

Can you help on this
The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

dpearsonConnect With a Mentor Commented:
The "jar" tool is part of the JDK (Java development toolkit).  You may just have the Java runtime.  Download the full JDK and you will get these extra tools like jar:

You can get the JDK from here:

Or you can use the rjar tool
to do a recursive search of all jars within a parent jar (and you wouldn't need the JDK - you'd just download rjar instead).

Mahesh BhutkarConnect With a Mentor Commented:
Simply go to your JDK bin path where you will find jar utility. Fire below command,

e.g. :-
C:\Program Files\Java\jdk\bin> jar tf <jarFileWithLocation> | find "button.class"

So in your case,
jar tf <path to TEST.jar> | find "button.class"
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.