JNI Interview Questions

1) How to get the window handle under the Microsoft JVM?

Bu using the AWT NI can get the window handle of a canvas. However, the Java application/applet is always subject to…

 import java.awt.*; import java.awt.peer.*; import com.ms.awt.peer.*; class DrawingCanvas extends java.awt.Canvas { void viewZoomBy(double. 

2) Are there JVM’s that work as a true 64-bit application?

IBM’s SDK for Windows on Itanium Solaris TM-SPARCTM platform edition of J2SDK 1.4.0 CACAO is 64 bit just-in-time (JIT) compiler for Java

3) Can I setup Tomcat to run inside the web server process itself (on Netscape/IIS?), instead of running it as a separate process.

Yes, Look for Tomcat documentation for clear idea.

4) How to use JNI on OpenVMS?

Please click the link http://www.slac.stanford.edu/grp/cd/soft/aida/using_jni_on_openvms.htm

5) What is BootClassPath and what we it can do in Java?

Please download this PDF www.javageeks.com/Papers/BootClasspath/BootClasspath.pdf

6) How can I create standalone Java applications that can be launched just like any other Mac OS application?

You can use JManager API or JBindery to do so. Here’s an article that shows you how to create a wrapper program around a Java application:

7) Is there an alternative to JNI on MacOS?

If you want to call Mac OS C code from your Java code, there are currently two mechanisms for doing so: JDirect2 and the Java Native Interface (JNI).

8) What are the changes to JAWT (AWT Native Interface) API in JDK1.4?

Added Lock() and Unlock() function pointers to the basic JAWT structure in jawt.h. These are needed to handle locking of the AWT without requiring a…

9) Am using -Xbootclasspath to add my custom jars, But this prevents loading custom JNI libraries from my user directory. Is there a work around?

That is the intended behavior. All system classes will only lookup shared libraries in $JAVA_HOME/bin. If you do need to load custom libraries for the system…

10) How can I use JBuilder to make my Java program into a native executable?

Borland Developer Support has an article on how to do this: How can I run my Java program as a native executable?

11) How to debug JNI code in CVM?

Porting Guide for the CDC and the Foundation Profile from SUN has a chapter on “C Debugging with GDB”.

12) How can I check the status of a java Thread using JVMDI?

// ThreadTool.java class ThreadTool { public static final int THREAD_STATUS_UNKNOWN = -1; public static final int THREAD_STATUS_ZOMBIE = 0; …

13) When reloading a Servlets that uses JNI, why do I get “java.lang.UnsatisfiedLinkError: Native Library D:\WINNT\mynamesearch.dll already loaded in another classloader” ?

The following link may shed some light on this: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4225434

14) Is there a COM Bridge that lets Windows developers create native client applications that access Enterprise JavaBeansTM (EJBTM) components deployed on a J2EE App server?

Yes. Take a look at: JavaTM 2 Platform, Enterprise Edition Client Access Services (J2EETM CAS) COM Bridge 1.0 Early Access.

15) What is necessary to have an applet call a native method? DLL installation, code signing, specific security permissions needed.

After more tries I solved the problem. I used your posted response about such a thing for Netscape. But was difficult to use that answer because Netscape…

16) JDK 1.4 has introduced the concept of direct buffers. Where can I get more information and/or samples for manipulating direct buffers?

JNI has been enhanced in v 1.4 to reflect a new feature of the java.nio package: direct buffers. The contents of a direct buffer can, potentially, reside…

17) What are the basic techniques for debugging mixed java and C++ code?

Debugging integrated Java and C/C++ code illustrates the two basic approaches using JNI (call C/C++ code from java, embed jvm in C/C++ code) and ways to…

EJB-JNI-Legacy Integration (C++ API) we have existing System in C++.We want to use Existing in the intranet/internet. We are using JNI to use existing System. And then we are calling JNI Classes in…

EJBs are supposed to be portable between different app servers who comply with the Sun’s specifications for compliant EJB containers. Because of this reason,

18) Anyone know of a way of marking a Java thread as being a demon if it was “created” through the JNI AttachCurrentThread call?

Through a new method called AttachCurrentThreadAsDaemon.

19) What is Signal Chaining mechanism that has been implemented in JDK 1.4?

Signal-chaining enables the Java Platform to better interoperate with native code that installs its own signal handlers. The facility works on both Solaris and Linux platforms.

The signal-chaining facility was introduced to remedy a problem with signal handling in previous versions of the Java Hotspot VM. Prior to version 1.4, the Java Hotspot VM would not allow application-installed signal handlers for certain signals including, for example, SIGBUS, SIGSEGV, SIGILL, etc, since those signal handlers could conflict with the signal handlers used internally by the Java Hotspot VM.

The signal-chaining facility offers:

  1. Support for pre-installed signal handlers when the Hotspot VM is created.
  2. Support for signal handler installation after the Hotspot VM is created, inside JNI code or from another native thread.

Pre-installed signal handlers (A) are supported by means of saving existing signal handlers, for signals that are used by the VM, when the VM is first created. Later, when any of these signals are raised and found not to be targeted at the Java Hotspot VM, the pre-installed handlers are invoked. In other words, pre-installed handlers are “chained” behind the VM handlers for these signals.

20) Is there a TCL-Java Bridge?

Yes, The Tcl/Java project currently has two packages, Jacl and Tcl Blend. Jacl, which stands for Java Command Language, is a Java implementation of Tcl…

21) Can I use JDI to monitor which the classes that are being loaded and information about which classloader is being used to load each of the classes?

 import java.io.*; 
import java.util.*; 
import com.sun.jdi.*; 
import com.sun.jdi.connect.*; 
import com.sun.jdi.event.*; 
import com.sun.jdi.requirement. 

22) What is JAWIN?

The Java/Win32 integration project is free, open source architecture for interoperation between Java and components exposed through Microsoft.

23) How can I start a shutdown without using JNI on my Windows box?

You can call Runtime.exec() and execute rundll32.exe with a few parameters. rundll32.exe shell32.dll, SHExitWindowsEx (to close the session) rundll32.exe.

24) How to make calls to C or C++ methods from a Servlets?

We have to use JNI.

25) Can I insert ActiveX controls in SWT?

Yes.

26) What is SWT?

SWT is the software component (part of the Eclipse IDE Framework) that delivers native widget functionality for the Eclipse platform in an operating…

27) How can I use JNI with WebSphere Application Server (WAS)?

One problem is that Servlets cannot load libraries because they are in a custom classloader. Move the Servlets to a location in the application server…

28) can I call activex control developed in VB/VC in java using JNI? Is it possible to call activex control developed in VB/VC from JAVA and if yes how?

Yes, it’s possible: Bridge2Java (from IBM alphaWorks) allows Java programs to communicate easily with ActiveX objects, using the JNI and COM technology….

29) Tools for Native Exe generation. What tools can I use to generate a native executable from my *.class files?

These tools fall into 2 categories. Those that package interpreted code into exes (wrappers) and those that actually compile the java code to machine…

30) How can I access java from Python (and the other way around)? Are there any JNI wrappers which can bridge the gap between the two?

JPE (Java-Python Extension) is an open-source effort for seamless inter-operability between Java and Python. Java-Python Extension main site JPE.

Comments

comments

About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.

Speak Your Mind

*