Click here to Skip to main content
15,888,610 members
Home / Discussions / Java
   

Java

 
GeneralRe: JavaFX program exit without Java JDK installed Pin
Richard MacCutchan25-Aug-18 5:47
mveRichard MacCutchan25-Aug-18 5:47 
GeneralRe: JavaFX program exit without Java JDK installed Pin
Richard MacCutchan25-Aug-18 4:35
mveRichard MacCutchan25-Aug-18 4:35 
GeneralRe: JavaFX program exit without Java JDK installed Pin
Valentinor25-Aug-18 4:55
Valentinor25-Aug-18 4:55 
GeneralRe: JavaFX program exit without Java JDK installed Pin
Richard MacCutchan25-Aug-18 6:12
mveRichard MacCutchan25-Aug-18 6:12 
GeneralRe: JavaFX program exit without Java JDK installed Pin
Valentinor25-Aug-18 7:24
Valentinor25-Aug-18 7:24 
GeneralRe: JavaFX program exit without Java JDK installed Pin
Richard MacCutchan25-Aug-18 8:29
mveRichard MacCutchan25-Aug-18 8:29 
GeneralRe: JavaFX program exit without Java JDK installed Pin
Valentinor25-Aug-18 8:46
Valentinor25-Aug-18 8:46 
AnswerRe: JavaFX program exit without Java JDK installed Pin
jschell25-Aug-18 4:50
jschell25-Aug-18 4:50 
The JRE will load JNI without problem.

I strongly suspect that your problem is as follows.
1 - You have inadequate error detection.
2 - You are loading the JNI via a static block. The JNI load fails which causes an exception. That by the way means that the class will also fail to load.

Other possibility is that the JNI code is throwing an exception. JNI code that throws system exceptions will cause the VM to exit.

Because of the exception and perhaps because of the class load failure, your application is getting an uncaught exception which causes the 'main' to exit. That means that the JRE exits.

For JNI

ALWAYS, load the class in a try catch block
ALWAYS, catch 'Throwable' (not Exception, not Runtime)
ALWAYS, log/print the exception stack trace. Not the message - the entire stack trace.
ALWAYS, do the above (catch, log) any method call that goes to a JNI method.

Note that the following loads the class. You should NOT have code like this in your main entry class. DO NOT attempt to load the class this way using another class either.

class MyClass
{
    private MyJNIClass somevar
    ...



Instead use a Interface and have a method and that method does a 'new' for your JNI class.

class MyJNIClass implements MyJNIInterface {...}

interface MyJNIInterface {}

class MyClass
{
    MyJNIInterface var;

    public void setup()
    {
        try
        {
         var = new MyJNIClass();
        }
        catch(Throwable e)
        {
           // Log/print the stack trace
           // Figure out what to do if it fails.
        }
     }



My last recommendation - do not use JNI.
If you want to access some other language
1. Create an executable with an IO Interface. IO interface would be via stdin/out, sockets, files, etc.
2. Create an API in your java app that runs 1, and uses the IO interface to talk to it.

The above solution means that failures in the other code cannot cause your VM to exit. The is NO way to stop this. That is why I recommend the above.
QuestionJava Heap Space: out of memory Pin
Member 1395683321-Aug-18 8:04
Member 1395683321-Aug-18 8:04 
AnswerRe: Java Heap Space: out of memory Pin
Richard MacCutchan21-Aug-18 21:23
mveRichard MacCutchan21-Aug-18 21:23 
AnswerRe: Java Heap Space: out of memory Pin
Member 1401730113-Oct-18 7:15
Member 1401730113-Oct-18 7:15 
Questionjava code for hadoop for builting data warehouse Pin
Shivendra chavan19-Aug-18 19:58
Shivendra chavan19-Aug-18 19:58 
AnswerRe: java code for hadoop for builting data warehouse Pin
Richard MacCutchan19-Aug-18 21:27
mveRichard MacCutchan19-Aug-18 21:27 
QuestionJava Pin
Member 1394945814-Aug-18 15:46
Member 1394945814-Aug-18 15:46 
AnswerRe: Java Pin
Richard MacCutchan14-Aug-18 20:42
mveRichard MacCutchan14-Aug-18 20:42 
AnswerRe: Java Pin
jschell19-Aug-18 7:36
jschell19-Aug-18 7:36 
AnswerRe: Java Pin
mohit gite22-Nov-18 22:46
mohit gite22-Nov-18 22:46 
AnswerRe: Java Pin
GiteHrudaya26-Nov-18 23:03
GiteHrudaya26-Nov-18 23:03 
Questionjavacode for read csv file without using jquery,jdbc,sql Pin
Member 1394487210-Aug-18 0:58
Member 1394487210-Aug-18 0:58 
QuestionRe: javacode for read csv file without using jquery,jdbc,sql Pin
Richard MacCutchan12-Aug-18 21:00
mveRichard MacCutchan12-Aug-18 21:00 
QuestionNew to this forum Pin
Member 1392578425-Jul-18 13:01
Member 1392578425-Jul-18 13:01 
AnswerRe: New to this forum Pin
Richard MacCutchan25-Jul-18 21:19
mveRichard MacCutchan25-Jul-18 21:19 
QuestionHelp to pick a career route Pin
Алексей Кузнецов15-Jul-18 21:10
Алексей Кузнецов15-Jul-18 21:10 
AnswerRe: Help to pick a career route Pin
Richard MacCutchan16-Jul-18 2:12
mveRichard MacCutchan16-Jul-18 2:12 
AnswerRe: Help to pick a career route Pin
jschell28-Jul-18 7:09
jschell28-Jul-18 7:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.