Date: Thu, 22 Jan 2015 12:09:51 +0100 From: "Ronald Klop" <ronald-lists@klop.ws> To: "Matthias Apitz" <guru@unixarea.de>, freebsd-java@freebsd.org, "Johannes Dieterich" <dieterich.joh@gmail.com> Subject: Re: executing Java written code from C pgm Message-ID: <op.xsu2mpztkndu52@ronaldradial.radialsg.local> In-Reply-To: <CABquGzVqV-kOVXkNdp9d=DQHEA=Of5tccmwo_vMCSFK8-Fo5nA@mail.gmail.com> References: <20150122102614.GA2046@c720-r276659> <CABquGzVqV-kOVXkNdp9d=DQHEA=Of5tccmwo_vMCSFK8-Fo5nA@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 22 Jan 2015 11:49:33 +0100, Johannes Dieterich <dieterich.joh@gmail.com> wrote: > Dear Matthias, > > On Thu, Jan 22, 2015 at 11:26 AM, Matthias Apitz <guru@unixarea.de> > wrote: >> >> Hello, >> >> I have some C/C++ written servers and want to use code (classes) written >> in Java. I figured out how the load the JVM and to reference into the >> class as C function calls. I can post the details if someone is >> interested it this. >> >> The problem is that the a.out must be linked against the JVM (libjvm.so) >> and the resulting process is around 300 MByte (text, data and bss), >> which makes it unusable in production (where some 200-300 processes of >> this are running). >> >> Is there some way to compile the Java code to machine code with needing >> a JVM to execute this? > You can try gcj from the GNU compilers. It can compile some Java code > to binary. That being said: last I tried, it failed for me for any > non-trivial code. Additionally, I believe it is stuck at around Java5 > which (fortunately, from my perspective) becomes rarer to use in the > Java world so odds are your classes will not compile. I recall also > seeing something llvm based lately, but I unfortunately cannot > remember the details anymore. > > Your best bet, in my opinion, is either into looking what exactly is > consuming so much memory, potentially optimizing it and coming up with > a different linking scheme (we all probably need more information on > your current setup to make an educated guess) or you could look into > porting your Java classes to C. > > You could look into having a standalone Java-server that communicated > with all the C servers via some interface. Again, this would require > some more details on your use case if this is a feasible way of > dealing with things. Personally, I would favor this route though. > > Sorry to not be able to be of more help, > > Johannes This would be my advise also. Ronald.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?op.xsu2mpztkndu52>