JNI and portability in java

Posted on 2006-11-22
Last Modified: 2013-11-22
I ve got a general question:
If I write a piece of functionality in c++ and make it provided to my java classes via JNI, what is the impact of this crossing on the portability of my java apllication , will it work on linux supposed that the c++ dlls compiled on windows xp or vice versa or not? how to solve this kind of non-portability due to JNI in case there is any?

Question by:TheSilverBullet
LVL 23

Accepted Solution

Ajay-Singh earned 125 total points
ID: 17994631
> will it work on linux supposed that the c++ dlls compiled on windows
> xp or vice versa or not?

may not work. so and dll are different. You need to recompile it on windows, linux

> how to solve this kind of non-portability due to JNI in case there is any?
a. Use pure java
b. Use #ifdef WIN32...
   for different platforms
LVL 86

Expert Comment

ID: 17994633
Portability is limited. You can try recompiling under each platform - depends on what you're doing
LVL 92

Expert Comment

ID: 17994676
depends on the portability of your C+ code. You solve it by making your native code portable.
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!


Author Comment

ID: 17995531
Hi All,
Thanks for your invaluable contributions. actually I need to get the creation date of a list of files, java supports only getting file modification date, which does not suffice in my case, since my main application is written in java I would need a way to walk around this, is there alternative to c++ that migh work on other operating systems, at least the linux flavours ?

do I need to ask this in another thread or does suffice only to increase the points here?
LVL 86

Expert Comment

ID: 17995554
Well different OSs treat file times in different ways too, so there again you would need to be in one #ifdef or other
LVL 92

Expert Comment

ID: 17999130
you're best asking in a different TA, as its not really a Java question.

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now