Jump to content

How to dynamically add jar to classpath at runtime


Recommended Posts

Posted (edited)

So, obviously this is for a private script because the repo wouldn't allow for this but..

 

So I have a class - http://pastebin.com/nBNu8Vga

 

And in my main script on start I have

java.io.File myJar = new File("C:\\Users\\Brian\\Downloads\\javax.mail.jar");
try {
CPath.addFile(myJar);
} catch (IOException e) {
e.printStackTrace();
}

But i get the same missing errors I would as if the classpath was never added, so it's not getting added.  Anyone have any ideas?

 

Edited by Brian
Posted

So, obviously this is for a private script because the repo wouldn't allow for this but..

 

So I have a class - http://pastebin.com/nBNu8Vga

 

And in my main script on start I have

try {
CPath.addFile("C:\\Users\\Brian\\Downloads\\javax.mail.jar");
} catch (IOException e) {
e.printStackTrace();
}

But i get the same missing errors I would as if the classpath was never added, so it's not getting added.  Anyone have any ideas?

 

Why are you trying to do that

 

Posted (edited)

I think you can just copy the jar in OSBot\Data


EDIT: nvm I remember now, I ragequitted and just copied the whole jar (I was using libgrowl) in my script jar. I guess dynamic loading isn't going to work since the classloader loads the script first and then tries to resolve any references. -cp isn't going to work either cuz osbot launches a new process...

Edited by Flamezzz

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...