Solved

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

Posted on 2014-01-14
6
702 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 27

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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ejb example issues 3 55
JAVA API design with micro service cloud in mind 1 82
Java Eclipse Loop 3 31
Where to place postgres JDBC driver jar on tomcat 8 31
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This video teaches viewers about errors in exception handling.

726 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