简体   繁体   English

为什么我的程序会抛出此JNI错误?

[英]Why does my program throw this JNI error?

So I have written a little JavaFX program that creates a local http server, receives pixel color input, and throws it all into a single image that can be saved. 因此,我编写了一个JavaFX小程序,该程序创建一个本地http服务器,接收像素颜色输入,并将其全部扔进一个可以保存的图像中。

The Problem: Whenever I try to run the program on a different computer I receive this error: 问题:每当我尝试在另一台计算机上运行该程序时,都会收到此错误:

在此处输入图片说明

However if the program is compiled on the "different computer" then the error is fixed and the program works as normal. 但是,如果程序是在“另一台计算机”上编译的,则该错误已修复,程序可以正常工作。 Having each new user download the JDK is and compiling the program theirselves is impractical so I am hoping to resolve this on my end. 让每个新用户下载JDK并自行编译程序是不切实际的,因此我希望最终解决此问题。

I have condensed the code to where I think the problem is, the rest is only boring JavaFX pane's and the what not. 我已经将代码压缩到我认为问题所在的位置,其余的只是无聊的JavaFX窗格,而其他的则不然。

import com.sun.net.httpserver.*;
import java.io.*;
import java.net.InetSocketAddress;
import java.awt.image.BufferedImage;
import javafx.embed.swing.SwingFXUtils;
import javax.imageio.ImageIO;
import java.util.*;

public void handle(HttpExchange exchanger) throws IOException{
            String response = "Request Recieved";
            exchanger.sendResponseHeaders(200,response.length());
            InputStream input = Exchanger.getRequestBody();
            String value = convertStreamToString(input);
            input.close();
            OutputStream output = exchanger.getResponseBody();
            output.write(response.getBytes());
            output.close();
            if (xTotal == 0 && yTotal == 0 && activated){
                    Scanner scan = new Scanner(value);
                    xTotal = scan.nextInt();
                    yTotal = scan.nextInt();
                    image = new WritableImage(xTotal,yTotal);
                    pixelWrite = image.getPixelWriter();
            }
            else{
                if (value.equals("StreamComplete")){
                    ExportImage.setDisable(false);
                }
                else{
                    int[][] tempArray = parseData(value);
                    if (tempArray.length > xTotal){
                        yCount++;
                        for (int i = 0; i < xTotal ; i++){
                            pixelWrite.setColor(i,yCount, Color.rgb(tempArray[i][0],tempArray[i][1],tempArray[i][2],1));
                        }
                        yCount++;
                        for (int i = xTotal; i < xTotal*2; i++){
                            pixelWrite.setColor(i-xTotal,yCount, Color.rgb(tempArray[i][0],tempArray[i][1],tempArray[i][2],1));
                        }

                    }
                    else{
                        yCount++;
                        for (int i = 0; i < xTotal ; i++){
                            pixelWrite.setColor(i,yCount, Color.rgb(tempArray[i][0],tempArray[i][1],tempArray[i][2],1));
                        }
                    }
                }
            }

Anyways I appreciate any help you guys can offer. 无论如何,我感谢你们提供的任何帮助。

Thanks 谢谢

So my really ugly fix to this error, was to boot up my other computer with an old version of the java JDK installed and compile it from there. 因此,对于此错误,我的真正丑陋的解决方法是用已安装的Java JDK的旧版本启动我的另一台计算机,然后从那里编译它。

Thanks to @Slaw for the help 感谢@Slaw的帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我的求和程序会抛出 NumberFormatException? - Why does my summation program throw a NumberFormatException? 为什么我的递归方法使我的程序抛出 InvalidClassException? - Why does my recursive method make my program throw an InvalidClassException? 为什么我的程序抛出“IndexOutOfBoundsException”,索引为:1,大小:0 - Why does my program throw an "IndexOutOfBoundsException", with Index: 1, Size: 0 为什么此Java程序引发NullPointerException? - Why does this Java program throw a NullPointerException? 为什么程序会在特定智能手机上引发 OutOfMemoryError? - Why does the program throw an OutOfMemoryError on a specific smartphone? 为什么我的 java 程序在 heroku 中使用 JDA 时会抛出 java.lang.NoSuchMethodError? - Why does my java program throw java.lang.NoSuchMethodError when using JDA in heroku? 为什么java在下面的排序程序中使用地址和指针时会报错? - Why does java throw an error when we use address and pointer for the following sorting program? 为什么我的程序停止运行并且不返回错误? - Why does my program stop running and does not return error? 为什么我的代码会抛出NullPointerException? - Why does my code throw a NullPointerException? 为什么我的 JSONParser 会抛出 NoClassDefFoundError? - Why does my JSONParser throw NoClassDefFoundError?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM