• Post Reply Bookmark Topic Watch Topic
  • New Topic

specifying additional jars at runtime  RSS feed

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've created an executable jar file with a mainfest file.

Im using java.exe to launch my application using the -jar option.

sadly using the -jar option means the CLASSPATH environment var is ignored

as is the -cp option for java.exe.

is there any way I can specify a wildcard in the mainfiest class-path
entry or something like that to pick up all the classes I require for my app
to execute.

my application uses reflection to interrogate classes, and I allow my users
to enter any class they like so obviously i do not know which classes I will need access to.

I could force them to move all there jars to a specific directory but I will not know the names of the jar files in question.

hopes that clear.


thanks for any help in advance

Cheers

Andy
 
Sheriff
Posts: 22844
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could always use a URLClassLoader to load classes from jar files that aren't in the classpath. You'd have to know where the jar file actually is, of course, but presumably the user is going to tell you that somehow.
 
andrew beechey
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul

thanks for you suggestion

I've given urlclassloader a "run out" and it doesnt do quite what Im after...

I was hoping for something where I could specify just a directory and it would load all the jar files within it amd as far as I can see
you have to specify the jar file by name or a base directory where the ".class" file can be found (within a package directory structure).

I've a feeling I'll have to create a custom classloader !

thanks for your time

Andy
 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A question on this topic:
jars that are in .../jre/lib/ext are supposed to be found automatically, right?

I have one pc where that's the case, another one where it isn't. Never understood why!
 
andrew beechey
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
are you sure the path is set corectly on the pc it doesnt work right on?

The ext option has always been a good "Plan B" in my experience

but what do I know?
 
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See if anything in this helps.
 
andrew beechey
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu

you are the "MAN" !

Nice

Cheers

Andy
 
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ko Wey:
A question on this topic:
jars that are in .../jre/lib/ext are supposed to be found automatically, right?

I have one pc where that's the case, another one where it isn't. Never understood why!

Because if you install the JDK on a PC, it doesn't only install the JDK, but also a separate JRE somewhere in C:\Program Files\Java.

If you put the JAR files in the .../jre/lib/ext in the JDK directory and you're running your program with the JRE in C:\Program Files, it's not going to find your JAR files.

You have to put the JAR files in the C:\Program Files\Java\...\jre\lib\ext directory too.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!