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.
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.
I have condensed the code to where I think the problem is, the rest is only boring JavaFX pane's and the what not.
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.
Thanks to @Slaw for the help
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.