简体   繁体   English

Eclipse上的控制台未显示任何内容

[英]Console on eclipse doesn't show anything

I try to run the Java code on eclipse. 我尝试在Eclipse上运行Java代码。 There is code like "system.out.print" but when i press run the console show this...... 有类似“ system.out.print”的代码,但是当我按下运行控制台时,显示此信息……

Invalid layout of java.lang.String at value 值的java.lang.String布局无效

A fatal error has been detected by the Java Runtime Environment: Java运行时环境检测到致命错误:

Internal Error (javaClasses.cpp:136), pid=2276, tid=2148 内部错误(javaClasses.cpp:136),pid = 2276,tid = 2148

fatal error: Invalid layout of preloaded class 致命错误:预加载类的布局无效

JRE version: (7.0_45-b18) (build ) JRE版本:(7.0_45-b18)(内部版本)

Java VM: Java HotSpot(TM) 64-Bit Server VM (24.45-b08 mixed mode windows-amd64 compressed oops) Java VM:Java HotSpot(TM)64位服务器VM(24.45-b08混合模式Windows-amd64压缩的oops)

Failed to write core dump. 无法写入核心转储。 Minidumps are not enabled by default on client versions of Windows 默认情况下,在客户端版本的Windows上不启用小型转储

An error report file with more information is saved as: C:\\Users\\Administrator\\Workspace\\Present\\Present\\hs_err_pid2276.log 包含更多信息的错误报告文件另存为:C:\\ Users \\ Administrator \\ Workspace \\ Present \\ Present \\ hs_err_pid2276.log

If you would like to submit a bug report, please visit: 如果您想提交错误报告,请访问:

http://bugreport.sun.com/bugreport/crash.jsp http://bugreport.sun.com/bugreport/crash.jsp

how to fix it. 如何解决。 help me please. 请帮帮我。 And here is the code i try to run... 这是我尝试运行的代码...

import Jama.Matrix;
import Jama.QRDecomposition;


public class LeastSquare {
private final int N;         // number of observations
private final int degree;    // degree of the polynomial regression
private final Matrix beta;   // the polynomial regression coefficients
private double SSE;          // sum of squares due to error
private double SST;          // total sum of squares


public LeastSquare(double[] x, double[] y, int degree) {
    this.degree = degree;
    N = x.length;

    // build Vandermonde matrix
    double[][] vandermonde = new double[N][degree+1];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= degree; j++) {
            vandermonde[i][j] = Math.pow(x[i], j);
        }
    }
    Matrix X = new Matrix(vandermonde);

    // create matrix from vector
    Matrix Y = new Matrix(y, N);

    // find least squares solution
    QRDecomposition qr = new QRDecomposition(X);
    beta = qr.solve(Y);


    // mean of y[] values
    double sum = 0.0;
    for (int i = 0; i < N; i++)
        sum += y[i];
    double mean = sum / N;

    // total variation to be accounted for
    for (int i = 0; i < N; i++) {
        double dev = y[i] - mean;
        SST += dev*dev;
    }

    // variation not accounted for
    Matrix residuals = X.times(beta).minus(Y);
    SSE = residuals.norm2() * residuals.norm2();
}


public double beta(int j) {
    return beta.get(j, 0);
}


public int degree() {
    return degree;
}


public double R2() {
    if (SST == 0.0) return 1.0;   // constant function
    return 1.0 - SSE/SST;
}


public double predict(double x) {
    // horner's method
    double y = 0.0;
    for (int j = degree; j >= 0; j--)
        y = beta(j) + (x * y);
    return y;
}


public String toString() {
    String s = "";
    int j = degree;

    // ignoring leading zero coefficients
    while (j >= 0 && Math.abs(beta(j)) < 1E-5)
        j--;

    // create remaining terms
    for (j = j; j >= 0; j--) {
        if      (j == 0) s += String.format("%.2f ", beta(j));
        else if (j == 1) s += String.format("%.2f N + ", beta(j));
        else             s += String.format("%.2f N^%d + ", beta(j), j);
    }
    return s + "  (R^2 = " + String.format("%.3f", R2()) + ")";
}

public static void main(String[] args) {
    double[] x = { 10, 20, 40, 80, 160, 200 };//
    double[] y = { 100, 350, 1500, 6700, 20160, 40000 };
    LeastSquare regression = new LeastSquare(x, y, 3);
    System.out.println(regression);
}

} }

It looks to me like your toString function may not be working, when you do your System.out.println(...) try this 在我看来,当您执行System.out.println(...)时,您的toString函数可能无法正常工作

System.out.println(regression.toString());

If that does not fix the issue then it is most likely something going wrong when setting the string to return from toString() 如果那不能解决问题,那么设置字符串从toString()返回时很可能出了问题。

jamolnng pretty much answered your question. jamolnng几乎回答了您的问题。 I ran into that problem once. 我曾经遇到这个问题。 Is your project Maven build? 您的项目是Maven构建的吗? If so, try: Remove maven nature from Right Click Project -> Maven -> Diasble Maven Nature. 如果是这样,请尝试:从右键单击Project-> Maven-> Diasble Maven Nature中删除Maven Nature。 Go to your terminal/command and pass this from your project directory "mvn clean install" 转到您的终端/命令,并从您的项目目录“ mvn clean install”中传递它

Go to your IDE and do Build-Clean (the project) And ebable the the project Maven Nature. 转到您的IDE并执行Build-Clean(该项目),然后进行项目Maven Nature。

And try running that & see if that helps. 并尝试运行它,看看是否有帮助。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM