Jump to content

How to dynamically add jar to classpath at runtime


Brian

Recommended Posts

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
Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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