Solved

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

Posted on 2014-01-14
6
463 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

746 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

10 Experts available now in Live!

Get 1:1 Help Now