我用matlab编写的算法,然后生成jar包要java来调用,可是始终都有问题,JVM崩溃掉了,我用的eclipse,显示的错误如下。
An unexpected error has been detected by Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d801117, pid=568, tid=1308
#
# Java VM: Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode)
# Problematic frame:
# C [jvm.dll+0x1117]
#
# An error report file with more information is saved as hs_err_pid568.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
Opening log file: C:\Users\WITKEY~1\AppData\Local\Temp\java.log.568
源代码如下
import operation.*;
import java.util.Scanner;
public class JavaTestMatlab
{
public static void main(String[] args)
{
Object result[] = null; /* object是所有类的父类public Object[] operation(int nargout, Object... rhs) */
operationclass myAdd = null; /* Stores myadd class instance */
try
{
int a,b;
myAdd = new operationclass();System.out.println("从键盘输入两个操作数:");
System.out.print(" 输入第一个操作数:");
Scanner scan = new Scanner(System.in); //从控制台读入输入的整数
a = scan.nextInt(); //从控制台输入第一个操作数
System.out.print(" 输入第二个操作数: ");
b = scan.nextInt(); //从控制台输入第二个操作数result = myAdd.operation(4,a,b); //operation(4,a,b)中第一个参数是返回值的个数 ,a是第一个输入参数,b是第二个输入参数
System.out.print("The sum of " + Integer.toString(a) + " and " + Integer.toString(b) + " is: ");
System.out.println(result[0]);
System.out.print("The sub of " + Integer.toString(a) + " and " + Integer.toString(b) + " is: ");
System.out.println(result[1]);
System.out.print("The mul of " + Integer.toString(a) + " and " + Integer.toString(b) + " is: ");
System.out.println(result[2]);
System.out.print("The div of " + Integer.toString(a) + " and " + Integer.toString(b) + " is: ");
System.out.println(result[3]);
}
catch (Exception e)
{
System.out.println(e);
}
}
}
求助高手帮小弟解答一下!
An unexpected error has been detected by Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d801117, pid=568, tid=1308
#
# Java VM: Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode)
# Problematic frame:
# C [jvm.dll+0x1117]
#
# An error report file with more information is saved as hs_err_pid568.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
Opening log file: C:\Users\WITKEY~1\AppData\Local\Temp\java.log.568
源代码如下
import operation.*;
import java.util.Scanner;
public class JavaTestMatlab
{
public static void main(String[] args)
{
Object result[] = null; /* object是所有类的父类public Object[] operation(int nargout, Object... rhs) */
operationclass myAdd = null; /* Stores myadd class instance */
try
{
int a,b;
myAdd = new operationclass();System.out.println("从键盘输入两个操作数:");
System.out.print(" 输入第一个操作数:");
Scanner scan = new Scanner(System.in); //从控制台读入输入的整数
a = scan.nextInt(); //从控制台输入第一个操作数
System.out.print(" 输入第二个操作数: ");
b = scan.nextInt(); //从控制台输入第二个操作数result = myAdd.operation(4,a,b); //operation(4,a,b)中第一个参数是返回值的个数 ,a是第一个输入参数,b是第二个输入参数
System.out.print("The sum of " + Integer.toString(a) + " and " + Integer.toString(b) + " is: ");
System.out.println(result[0]);
System.out.print("The sub of " + Integer.toString(a) + " and " + Integer.toString(b) + " is: ");
System.out.println(result[1]);
System.out.print("The mul of " + Integer.toString(a) + " and " + Integer.toString(b) + " is: ");
System.out.println(result[2]);
System.out.print("The div of " + Integer.toString(a) + " and " + Integer.toString(b) + " is: ");
System.out.println(result[3]);
}
catch (Exception e)
{
System.out.println(e);
}
}
}
求助高手帮小弟解答一下!
java在调用dll函数时,如果dll文件出现内存错误,java虚拟机就会崩溃,没有办法避免。并且错误日志,和你贴的日志相似,都是内存出错。
也就你的java程序在调用matlab程序是。参数之类的东西传送错误,导致matlab程序出现内存错误。
是的,你最好在matlab的jar包中 输入日志,跟踪错误。