How to find packages/class files?

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?  
TaurusAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jimmackCommented:
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
TaurusAuthor Commented:
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
TaurusAuthor Commented:
Whoops the second URL above was supposed to be: http://www.obsolete.com/people/cansdale/java/class_spider/index.htm
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

jimmackCommented:
>> 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TaurusAuthor Commented:
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
TaurusAuthor Commented:
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
tapasviCommented:
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
tapasviCommented:
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
TaurusAuthor Commented:
Thanks tapasvi, I'll check it out.
0
jimmackCommented:
;-)

Thanx Taurus
0
jimmackCommented:
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
TaurusAuthor Commented:
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
jimmackCommented:
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
TaurusAuthor Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.