LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-16-2008, 07:02 AM   #1
Shautieh
Member
 
Registered: Sep 2006
Distribution: Ubuntu
Posts: 64

Rep: Reputation: 15
Java in C++, and vice versa (JNI ?)


Hello !

I'm sorry but this post will be quite lengthy

I am part of a project (symphonic) which intends to bypass the shitty sonic stage so we can manage our musics on our sony audio players. To explain the problem, I'll make a quick historic :
- a first app was made in Java with basic features ;
- someone else made a library for winamp with more advanced features in c++ (and bound on windows) ;
- it was decided to modify this library so it would run on linux, but in the meantime the java program was upgraded to the point it has nearly as much features as this library now.

So, the problem now is that there are 2 internal projects which intend to do the same thing. It was decided that the c++ one would become the main project in the future, but the java one won't be stopped so it's like, twice as much work -_-

+/- of the java program : can be run on all system directly from the audio player disk
+/- of the c++ program : they absolutely want the project to work as an amarok plugin (or other audio players' plugins), so it seems a java program won't do.

The idea is, won't it be easier in the long run to chose only one language, and then use JNI or something (don't know anything about it as far as now) ?? And if yes, do you think it would be better to have the core in c++ and some sort of java launcher, or the core in java and a c++ interface to use it ?

I am thinking of a java core and a c++ interface for the plugins' purposes, but as I don't know much about JNI I'd like to know what you think about it Any suggestions are really welcome !


Thanks !
 
Old 03-16-2008, 07:30 AM   #2
Simon Bridge
Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 197Reputation: 197
Have you considered just using gcj?
http://linux.die.net/man/1/gcj
http://www.gnu.org/software/gcc/java/
Quote:
GCJ is a portable, optimizing, ahead-of-time compiler for the Java Programming Language. It can compile Java source code to Java bytecode (class files) or directly to native machine code, and Java bytecode to native machine code.
 
Old 03-16-2008, 11:17 AM   #3
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
I think your problem will be with linking, not actually the in-code tasks. Remember that C++ libs have compiler-dependent mangled names, so you might be better off giving the library a C API while retaining C++ internally.
ta0kira
 
Old 03-16-2008, 11:43 AM   #4
Shautieh
Member
 
Registered: Sep 2006
Distribution: Ubuntu
Posts: 64

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Simon Bridge View Post
It seems to compile the java classes into executable code, but how should it help me ? I don't know how to use it from within the c++ program then

Quote:
6.2 Is it possible to invoke GCJ compiled Java code from a C++ application?

Yes, GCJ 3.1 supports a CNI-based invocation interface as well as the traditional JNI invocation API. See the GCJ Manual for more details on how to use the CNI interface.
I could use CNI direcly then, maybe.. ?


@TaOkira : so you think the application core should be in c++, and I'll be able to make a java front end which can use it ? (via a C API ?)


edit: having searched about it a bit more, I think the best would be to continue the java program (so it can be launched almost anywhere), and use JNI or CNI (on the compiled java code or not.. ?) so it can be called by c or c++ code for the audio players plugins. I need to be sure this is doable though, but it should be the right path..

Last edited by Shautieh; 03-16-2008 at 12:34 PM.
 
  


Reply

Tags
c++, java


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What does Linux have against ASUS (or vice versa)? xp_newbie Linux - Hardware 54 05-23-2007 11:24 AM
LXer: Windows to Linux, and vice versa LXer Syndicated Linux News 0 04-24-2006 03:03 PM
m1 can ping m2, but not vice versa cmacklin Linux - Networking 4 10-31-2004 08:01 PM
KDE under Gnome, or vice-versa Pres General 7 02-01-2004 10:18 AM
Samba sees Windows but not vice versa Jeffssac Linux - Networking 6 06-26-2003 12:05 PM


All times are GMT -5. The time now is 03:04 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration