• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Getting classes in a package

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I’m trying to make a extended class that get automatically test classes from a package. I know the packagename and path. But I don’t know how I can get the classes from it.
Someone an idea?
 
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Read importing package members here - Java tutorials - Using package members
 
Gynnad Paullussen
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

John Jai wrote:Read importing package members here - Java tutorials - Using package members



Hmm.. I don't think that is what I'm searching for..

What I want is that I start a program that will find another JAR that starts the JUnit tests of that JAR. I found this code, but I get the error JAR IS NULL..



But the String s is the direct link to the Jar file and it is correct..
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Gynnad Paullussen wrote: I get the error JAR IS NULL..


This is not an error, this message merely indicates that there is no more jar entries.
Add printing of jarEntry.getName () to see if there are jar entries at all.
 
Gynnad Paullussen
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Alexei Kaigorodov wrote:

Gynnad Paullussen wrote: I get the error JAR IS NULL..


This is not an error, this message merely indicates that there is no more jar entries.
Add printing of jarEntry.getName () to see if there are jar entries at all.



Then I see everything what is in the jar.. But why does the code not work then?
 
Gynnad Paullussen
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Gynnad Paullussen wrote:

Alexei Kaigorodov wrote:

Gynnad Paullussen wrote: I get the error JAR IS NULL..


This is not an error, this message merely indicates that there is no more jar entries.
Add printing of jarEntry.getName () to see if there are jar entries at all.



Then I see everything what is in the jar.. But why does the code not work then?





I changed the jarEntry in the if to jarEntry.getName() and now it is working to get the .class files.

Now I have the path in the jar to the classes that contains the tests. For example this is a class with tests: test.login.deploy.AllTest.class But that is a String and not the class. And I need in my program the class to start the JUnit tests. This is the code that I'm using for it:



I know now the path to the .Jar file and from the Jar file the way to the classes I need. But how can I run them now? Because when I'm running them he searches in my own jar file...
reply
    Bookmark Topic Watch Topic
  • New Topic