• Post Reply Bookmark Topic Watch Topic
  • New Topic

Listing out all of the jar files in a .classpath file  RSS feed

 
Skip Cole
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You know, this really drove me crazy today, because it is something that should be very simple to do.

I have two .classpath files, and I want to compare all of the jar files that they use. Since the path information may be different, I wanted to just get the list of everything '.jar'.

So a line like, '<classpathentry kind="lib" path="C:/apache-tomcat-8.0.99/lib/servlet-api.jar"/>', would just produce 'servlet-api.jar'

So I tried with grep and then sed and then java regex (Pattern and Matches) and finally String.split(). I finally got my what I wanted, but it wasn't pretty.

There has to be a simple way to use a regular expression to look through a file and get all /*.jar

What is it? And before you answer without testing your code, be advised, I must have tried 100 things that I was Sure would work, but did not.

Thanks in advance,
Skip
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i won't swear to it, but:
(.*)/([-a-z]*.jar)

seems to work for the line provided, according to my regex tool.
 
Paul Clapham
Sheriff
Posts: 22819
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But these are XML files, aren't they? So I would just parse the two documents and find everything which matches the XPath expression "//classpath/@path". Then you just have two lists to compare.

Hopefully that isn't one of the 100 things you tried, because it's untested.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!