Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Getting classes in a package

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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...
 
Power corrupts. Absolute power xxxxxxxxxxxxxxxx is kinda neat.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic