Solved

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

Posted on 2014-01-14
6
518 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 26

Assisted Solution

by:dpearson
dpearson earned 166 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 6

Assisted Solution

by:Mahesh Bhutkar
Mahesh Bhutkar earned 167 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 167 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

920 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now