Loading a class from a jar

19 Aufrufe
Direkt zur ersten ungelesenen Nachricht

aditya

ungelesen,
01.03.2013, 10:47:2401.03.13
an scala...@googlegroups.com
Hey 

The problem is something like this:
I have a the name of the class which contains a function I want to run. When my app executes, I give it the name, and it searches through all jars in /extern-libs and tries to find the class. If this class is found, it creates an instance of this and runs the function.

Any ideas on how this can be accomplished?


Alex Cruise

ungelesen,
01.03.2013, 17:44:2201.03.13
an aditya, scala-user
Here are a couple ways:

The old school way: http://docs.oracle.com/javase/1.4.2/docs/guide/jar/jar.html#Service Provider

I've also used Brian Clapper's ClassUtil: http://software.clapper.org/classutil/

-0xe1a




--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Flavio W. Brasil

ungelesen,
01.03.2013, 17:54:1601.03.13
an Alex Cruise, aditya, scala-user

-- 
Flávio W. Brasil
{persistence as it should be}

Aditya Vishwakarma

ungelesen,
01.03.2013, 22:04:2601.03.13
an Flavio W. Brasil, Alex Cruise, scala-user
Thanks. Are there any libraries which use 2.10 reflection ? 

Aditya Vishwakarma

Flavio W. Brasil

ungelesen,
02.03.2013, 10:12:0102.03.13
an Aditya Vishwakarma, Alex Cruise, scala-user
I don't know if it is possible to scan jars using the scala 2.10 reflection.
To reflect the found classes you can use smirror.

-- 
Flávio W. Brasil
{persistence as it should be}

Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten