From owner-freebsd-java@FreeBSD.ORG Thu Jan 22 11:25:14 2015 Return-Path: Delivered-To: freebsd-java@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0508525C for ; Thu, 22 Jan 2015 11:25:14 +0000 (UTC) Received: from smarthost1.greenhost.nl (smarthost1.greenhost.nl [195.190.28.81]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B8A9E31B for ; Thu, 22 Jan 2015 11:25:13 +0000 (UTC) Received: from smtp.greenhost.nl ([213.108.104.138]) by smarthost1.greenhost.nl with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1YEFe5-0007fB-33; Thu, 22 Jan 2015 12:09:58 +0100 Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes To: "Matthias Apitz" , freebsd-java@freebsd.org, "Johannes Dieterich" Subject: Re: executing Java written code from C pgm References: <20150122102614.GA2046@c720-r276659> Date: Thu, 22 Jan 2015 12:09:51 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: "Ronald Klop" Message-ID: In-Reply-To: User-Agent: Opera Mail/1.0 (Win32) X-Authenticated-As-Hash: 398f5522cb258ce43cb679602f8cfe8b62a256d1 X-Virus-Scanned: by clamav at smarthost1.samage.net X-Spam-Level: / X-Spam-Score: -0.2 X-Spam-Status: No, score=-0.2 required=5.0 tests=ALL_TRUSTED, BAYES_50 autolearn=disabled version=3.3.2 X-Scan-Signature: 1f72ff50073f138f9668c095d6f579a1 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Jan 2015 11:25:14 -0000 On Thu, 22 Jan 2015 11:49:33 +0100, Johannes Dieterich wrote: > Dear Matthias, > > On Thu, Jan 22, 2015 at 11:26 AM, Matthias Apitz > 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.