?
Solved

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

Posted on 2014-01-14
6
Medium Priority
?
1,231 Views
Last Modified: 2014-01-15
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

java.lang.NullPointerException

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

Thanks
0
Comment
Question by:Los Angeles1
6 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 39780269
http://technojeeves.com/joomla/index.php/free/45-jarsearch
 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
0
 

Author Comment

by:Los Angeles1
ID: 39780344
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
0
 
LVL 28

Assisted Solution

by:dpearson
dpearson earned 664 total points
ID: 39780935
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:

http://docs.oracle.com/javase/tutorial/deployment/jar/basicsindex.html

You can get the JDK from here:
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

Or you can use the rjar tool
https://code.google.com/p/rjar/
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).

Doug
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 6

Assisted Solution

by:Mahesh Bhutkar
Mahesh Bhutkar earned 668 total points
ID: 39781448
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"
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 668 total points
ID: 39782089
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
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39782755
:)
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month15 days, 2 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question