473,804 Members | 3,147 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Call Java functions in a C DLL

Hi,

I am develop a dynamic link library in C on AIX that will internally
call java functions using JNI. This libaray will be finally used by
other C Executable.

There is only one function in C code i.e. Connect. This function
internally use JNI and call java functions. Now while compiling I am
facing problems. I think that there is some problem with my makefile.

The make file is given hereunder:

JAVA_HOME = /usr/java14
JAVA_INC = $(JAVA_HOME)/include

CC = cc
LD = cc

# Flags to create a dynamic library.
DYNLINKFLAGS = -G -ostdlib -bnoentry -bM:SRE -brtl -bE:Interface.ex p

# files removal
RM = rm -f

#------------------------------------- Libs
-----------------------------------#
JAVALIBS = -L$(JAVA_HOME)/jre/bin/classic/
LIBS = -ljvm -lpthread -lxnet -lnsl -lm -ldl
#-------------------------------- Dependency
rules---------------------------#
# shared library files
LIB_FILES = Interface.a
#-------------------------------------
OBJs-------------------------------------#
# shared libraries object files
LIB_OBJS = Interface.o

all: $(LIB_FILES)
# create our librarys
Interface.a: Interface.o
$(LD) $(DYNLINKFLAGS) $(JAVALIBS) $(LIBS) $(LIB_OBJS) -o $@

# compile C source files into object files.
%.o: %.c
$(CC) $(DYNLINKFLAGS) -L$(JAVA_INC) -c $<

# clean everything
clean:
$(RM) $(LIB_OBJS) $(LIB_FILES)

# clean the library's object files only
cleanlibobjs:
$(RM) $(LIB_OBJS)

Now the problem is that library is not properly created because the
size of the Interface.a file is very small only 552 bytes. whereas the
size of Interface.o file is 34428. Which clearly indicates that the
problem is with the Interface.a file i.e during linking.

Can any body help me to figure out the problem.

Regards,

Ahmad Jalil Qarshi
Oct 20 '08 #1
1 2572
Ahmad Jalil Qarshi wrote, On 20/10/08 23:33:

<snip>
There is only one function in C code i.e. Connect. This function
internally use JNI and call java functions. Now while compiling I am
facing problems. I think that there is some problem with my makefile.
<snip>

Make files are not topical on comp.lang.c nor is how to interface to
Java (because it is JAva that specifies this not C). Please keep the
discussion of this on groups where it is topical, and I'm guessing that
comp.unix.progr ammer and/or comp.unix.aix might be appropriate.
--
Flash Gordon
If spamming me sent it to sm**@spam.cause way.com
If emailing me use my reply-to address
See the comp.lang.c Wiki hosted by me at http://clc-wiki.net/
Oct 20 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2877
by: Kouts | last post by:
Hello all! I would like to ask something regarding dlls and Java: I would like to transform my Java code to a dll, in order to allow to third party applications (e.g. VB or Power Builder applications ) to call specific functions (previously exposed by me) from this dll. Is this possible in Java? (I have made the same from PowerBuilder and MDev Studio-C++). Generally, is any other way to do it (to expose Java code-functions to third party...
6
22340
by: Dave Kuhlman | last post by:
Is JPE (the Python Java Extension) being used widely/actively? I tried to build it (with Python 2.3.4, j2se 1.4 on Debian GNU/Linux) and had quite a bit of trouble. And, then, the samples did not run. Is there another way to call Java code from Python? The JPE project does not seem too active lately, or is it?
25
3345
by: Digital Puer | last post by:
I'm looking at some software development jobs whose listings require C++ experience. My history is that I have a strong C background, and a few years of C++ from undergrad classes. I've been working with Java since 1997 and consider myself a decent Java programmer. Now, if I apply for C++ jobs, do you think it's important that I know the fine details of C++? or would a strong, generalised knowledge of object-oriented programming be more...
39
6570
by: Randell D. | last post by:
Folks, I'm sure this can be done legally, and not thru tricks of the trade - I hope someone can help. I'm writing a 'tool' (a function) which can be used generically in any of my projects. When it completes, it can call a success, or a failure function. The names of these success, or failure functions will differ, and I'd like to know how I can pass the name of a function to my tool, and how my tool can call the function, using that...
9
1551
by: Paul Bilnoski | last post by:
Can someone explain why a call to a virtual function within a constructor is illegal? The class can't be instantiated because functions are abstract, so whatever extends it implements them which means they should be implemented when the constructor for the base is called. Is it because the base gets constructed before the rest of the object and the vftable doesn't exist? I think something like this works in Java. class AbstractBase
35
10801
by: hasho | last post by:
Why is "call by address" faster than "call by value"?
46
3866
by: Steven T. Hatton | last post by:
I just read §2.11.3 of D&E, and I have to say, I'm quite puzzled by what it says. http://java.sun.com/docs/books/tutorial/essential/concurrency/syncrgb.html <shrug> -- NOUN:1. Money or property bequeathed to another by will. 2. Something handed down from an ancestor or a predecessor or from the past: a legacy of religious freedom. ETYMOLOGY: MidE legacie, office of a deputy, from OF, from ML legatia, from L legare, to depute, bequeath....
6
6683
by: Christopher | last post by:
Its been awhile and I am rusty. Can the constructor of my class call another method in the same class if that other method does not change any member data? I want to simply have a seperate method that returns a huge string, that string containing code in another language, which is to be compiled by a third party API when my object is being contructed. class MyClass()
5
10773
madzman23
by: madzman23 | last post by:
Hi guyz, I kinda new here and I dont know if there is post that similar to my question, because I really needed immediately I am posting my question. Can anyone here help me how to call a Java Program using the PHP. The PHP code should call a Java program that will extract all the data from the database, I know we can do this in PHP, but I want a more secure one so I want to make a prototype that will call the Java Program that get all the...
0
9708
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10340
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10324
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10085
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7623
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4302
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.