public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
* Dynamic Class Loading in GCJ
@ 2008-12-25  1:18 Tushar kant
  2008-12-25  2:39 ` BGB
  2008-12-25 10:39 ` Andrew Haley
  0 siblings, 2 replies; 4+ messages in thread
From: Tushar kant @ 2008-12-25  1:18 UTC (permalink / raw)
  To: java

Hi! I'm writing an application in Java  using GCJ and would like to
add a plug-in feature to it. I have searched the internet a lot but
couldn't find a way to dynamically load .class\.so files dynamically.
I would really appreciate it if someone could help me on this.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Dynamic Class Loading in GCJ
  2008-12-25  1:18 Dynamic Class Loading in GCJ Tushar kant
@ 2008-12-25  2:39 ` BGB
  2008-12-25 10:39 ` Andrew Haley
  1 sibling, 0 replies; 4+ messages in thread
From: BGB @ 2008-12-25  2:39 UTC (permalink / raw)
  To: Tushar kant, java


----- Original Message ----- 
From: "Tushar kant" <tusharkant15@gmail.com>
To: <java@gcc.gnu.org>
Sent: Thursday, December 25, 2008 11:18 AM
Subject: Dynamic Class Loading in GCJ


> Hi! I'm writing an application in Java  using GCJ and would like to
> add a plug-in feature to it. I have searched the internet a lot but
> couldn't find a way to dynamically load .class\.so files dynamically.
> I would really appreciate it if someone could help me on this.
>

I don't know the details (not being a Java developer), but I think there is 
something for this in the class library somewhere (I don't know if in 
general, or VM specific).

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Dynamic Class Loading in GCJ
  2008-12-25  1:18 Dynamic Class Loading in GCJ Tushar kant
  2008-12-25  2:39 ` BGB
@ 2008-12-25 10:39 ` Andrew Haley
  1 sibling, 0 replies; 4+ messages in thread
From: Andrew Haley @ 2008-12-25 10:39 UTC (permalink / raw)
  To: Tushar kant; +Cc: java

Tushar kant wrote:
> Hi! I'm writing an application in Java  using GCJ and would like to
> add a plug-in feature to it. I have searched the internet a lot but
> couldn't find a way to dynamically load .class\.so files dynamically.
> I would really appreciate it if someone could help me on this.

Here's a really simple example:

foo.java:

import java.net.*;

public class foo
{
  public static void main(String[] argv)
    throws Exception
  {
    ClassLoader l
      = (new URLClassLoader
	 (new URL[] {new URL("gcjlib://"
			     + System.getProperty("user.dir")
			     + "/libpop.so")}));
    Class<?> C = l.loadClass("pop");
    C.newInstance();
  }
}

pop.java:

public class pop
{
  pop()
  {
    System.out.println("Cooee!");
  }
}

 $ gcj foo.java  -o foo --main=foo
 $ gcj -findirect-dispatch -Wl,-Bsymbolic -shared pop.java -o libpop.so -fpic

 $ ./foo
Cooee!

Gcj has lots of other class loading mechanisms that you might find useful.
All this, and more, is explained in the gcj documentation.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Dynamic Class Loading in GCJ
       [not found] <32ae3bf80812232130q1bebdb8td3ece71a1e8ef593@mail.gmail.com>
@ 2008-12-24 17:39 ` David Daney
  0 siblings, 0 replies; 4+ messages in thread
From: David Daney @ 2008-12-24 17:39 UTC (permalink / raw)
  To: Tushar kant; +Cc: gcc-help, Java List

Tushar kant wrote:
> Hi! I have searched the Internet a lot but I just don't seem to find a
> way to dynamically load .so files in gcj. I am writing an application in
> java and I want it to be able to load external plugins during execution
> time. I would appreciate it if some one could help me out on this
> problem.

Ask over on java@ (CCed here).

It should work for many things.  If you have specific problems, we may 
be able to help.

David Daney

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-12-25 10:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-25  1:18 Dynamic Class Loading in GCJ Tushar kant
2008-12-25  2:39 ` BGB
2008-12-25 10:39 ` Andrew Haley
     [not found] <32ae3bf80812232130q1bebdb8td3ece71a1e8ef593@mail.gmail.com>
2008-12-24 17:39 ` David Daney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).