Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to find packages/class files?

Posted on 2003-12-11
14
Medium Priority
?
618 Views
Last Modified: 2010-03-31
I've been compiling JAXB auto generated code and keep having to hunt down the jar files for specific JAXB packages and or class files.  Latest example that the compiler is complaining doesn't exist is "com.sun.msv.datatype.xsd.TimeType".  I'm using the latest Netbeans IDE under Windows 2000.  Anyone know of a utility and or way in Netbeans to hunt down and or look up these class files?  
0
Comment
Question by:Taurus
  • 7
  • 5
  • 2
14 Comments
 
LVL 15

Expert Comment

by:jimmack
ID: 9924357
I've written an application that does exactly what you're looking for (for exactly the same reason).

I haven't sorted out the packaging for distribution yet because I've been "busy" doing other things.  Your question has prompted me to get on with it.  If I can get it sorted out before you get another alternative, I'll post again to let you know where to download it.

(Eventually, it will be freely downloadable from my web site - when I get that updated too ;-))
0
 

Author Comment

by:Taurus
ID: 9924807
That would be nice.  When do you think you will have it?  I did do some searching and found:
http://www.zipscan.co.uk/
I may use it, unless yours is done soon or I can figure out how to make the Netbeans IDE do a search.  It will search Jar files but it seems one must mount them directly which is pretty tedious and creates a multistep process when it should be one step.

On another note, do you know if likewise there is a utility to show just which classes an application utilizes, and extract them to a temporary directory so that they can be repackaged into one compact .jar? Or will just do it without the temporary directory.  FYI and for reference here is an application that used to do something similar:
http://www.zipscan.co.uk/
0
 

Author Comment

by:Taurus
ID: 9924862
Whoops the second URL above was supposed to be: http://www.obsolete.com/people/cansdale/java/class_spider/index.htm
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 15

Accepted Solution

by:
jimmack earned 400 total points
ID: 9924881
>> On another note, do you know if likewise there is a utility to show just which classes an application utilizes, and extract them to a temporary directory so that they can be repackaged into one compact .jar?

I wish!  ;-)  I could have done with that for this packaging problem :-)

OK.  I've got the package together.  You can download it (temporarily) from:

http://www.ossmobile.co.uk/ClassFinder/ClassFinder.zip

I would really appreciate it if you could provide some feedback on it.

To any other experts who may be considering downloading this application - I would appreciate it if you could hold-off for now.  The tool is still not ready to be released into the wild.  However if you insist on looking at it, I would consider it a professional courtesy if you would also provide feedback.
0
 

Author Comment

by:Taurus
ID: 9925140
I downloaded it and tested on the class I just was trying to find.  It worked excellently.  Big thanks, it will be a real time saver.  

Per feedback, here are some minor suggestions(I'll e-mail you directly if I have more):
1) Per removing sources, it would be nice if one could use the delete key or be able to right click and get a context menu with a delete option.
2)  Maybe add the capability to be able to put in multiple search strings at one time.
3)  Maybe add a button to clear the results window.
4)  When you distribute the Jars you might just mention the location of the file that contains the main method.
0
 

Author Comment

by:Taurus
ID: 9925294
Does anyone know a way to get the list of class dependencies from the compiler?  Given that information it would be easy to extend this application so that it would create a jar with "only" the necessary classes. :)
0
 
LVL 4

Assisted Solution

by:tapasvi
tapasvi earned 120 total points
ID: 9925966
This code finds a given class file in all the jar files under DIR_NAME.

you may need to change DIR_NAME field.

---------------------------------


import java.io.File;
import java.io.IOException;
import java.util.jar.JarFile;
import java.util.Enumeration;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.util.StringTokenizer;

public class TestJar
{
   public static void main(String[] args)
   {
            if(args.length != 1)
            {
                  System.out.println("USAGE: java TestJar <class file name>");
            }
            else
            {
                  JarFile   jf = null;
                  Matcher m = null;
                  String token = "";
                  StringTokenizer st = null;
                  StringBuffer sb = null;
                  final String DIR_NAME = "\\\\bng-tv4850\\bea\\weblogic81\\server\\lib";
                  File dirName = new File (DIR_NAME);
                  String[] fileList = dirName.list();
                  Pattern p = Pattern.compile("[a-zA-Z]*"+args[0]+"[a-zA-Z]*");
                  try
                  {
                        //System.out.println("Directory content is ");
                        outer:for (int i=0; i < fileList.length;i++)
                        {
                           sb = new StringBuffer();
                           //System.out.println(fileList[i]);
                           if(Pattern.matches("[a-zA-Z]*[.]jar", fileList[i]))
                           {
                                    jf = new JarFile(DIR_NAME+"\\"+fileList[i]);
                              inner:for (Enumeration e = jf.entries(); e.hasMoreElements() ;)
                                  {
                                           sb.append(e.nextElement());
                                     }
                                    st = new StringTokenizer(sb.toString(),"/");
                                    while (st.hasMoreTokens())
                                    {
                                          token = st.nextToken("/");
                                          m = p.matcher(token.trim());
                                          if( m != null && m.matches())
                                          {
                                                System.out.println(args[0] +" file is in "+jf.getName());
                                                break outer;
                                          }
                                    }

                               }
                        }
                  }
                  catch(IOException e)
                  {
                        e.printStackTrace();
                  }
            }
   }

}
0
 
LVL 4

Expert Comment

by:tapasvi
ID: 9925983
Hi to Taurus from a Taurus ;-)

http://classycle.sourceforge.net/ may be useful to u for class dependency find.

I havent tried it out myself..:-(


0
 

Author Comment

by:Taurus
ID: 9926037
Thanks tapasvi, I'll check it out.
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9927481
;-)

Thanx Taurus
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9927653
Taurus,

  Thanx for the suggestions :-)  I'm glad (relieved ;-)) it worked.  I would appreciate it if you could let me know:

  1) What OS have you run it on (I've only given it a good hammering on Linux)?
  2) Do you think that the way it was packaged was acceptable?
0
 

Author Comment

by:Taurus
ID: 9929759
I ran it on Windows 2000 Server.  When you say packaged, do you mean the UI or the jar files?  I just unzipped the jars to a directory, mounted them with the Netbeans IDE, located the file with main(), and ran it.  I didn't have webstart loaded so it wasn't a one step process.  Webstart was included with the JDK&Netbeans distribution, but it didn't install.  
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9931560
Oh, OK ;-)

I packaged it into a jar and included a readme file for running it from the command line.  If it worked with no problems from within Netbeans, that's even better news ;-)

I've put in two of the changes you suggested - delete key and clear button.  I'll post on this question again when I've published it properly on my web site.

Thanx again.

Jim.
0
 

Author Comment

by:Taurus
ID: 9932646
I briefly tried the classycle app that tapasvi referenced.  It seemed to spit out a list of class dependencies that looked, at a glance, correct.  I would further refine my suggestion regarding the app allow multiple search queries at once and then have an option to select one or more search result classes and have them extracted to a designated directory.  You would need to create subdirectories under the designated dir, to match the package hierarchy or have that option at least.  This would be great don't you think:)

Whether or not you do this your app. is a life saver.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Suggested Courses
Course of the Month15 days, 5 hours left to enroll

578 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