【发布时间】:2015-01-19 22:46:17
【问题描述】:
我使用 Eclipse 已经有一段时间了,但我最近刚刚遇到一个错误,现在我真的很烦,因为我无法使用调试器。我可以正常运行我的程序,但不能正常运行调试器。这是我尝试使用调试器运行时得到的结果:
“启动 CarLoanUser”遇到问题 无法连接到虚拟机 无法连接到虚拟机 com.sun.jdi.connect.TransportTimeoutException
在控制台中:
本机方法中的致命错误:JDWP 未初始化传输, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197) 错误:传输错误 202: 连接失败:权限被拒绝错误:JDWP 传输 dt_socket 初始化失败,TRANSPORT_INIT(510) JDWP 退出错误 AGENT_ERROR_TRANSPORT_INIT(197):没有初始化传输 [debugInit.c:750]
我已经尝试了很多关于它的事情:
- 重启 Eclipse
- 重启我的电脑
- 试试我拥有的另一个代码
- 重新安装 Eclipse (Luna)
- 删除 Eclipse (Luna) 并将其替换为 Eclipse Java EE (Kepler)
- 返回 Eclipse (Luna)
- 卸载所有 Java 实例并安装 Java 8
- 卸载 Java 8 并安装 Java 7(所有 Java 安装均使用 64 位安装程序)
- 使用 ccleaner 清理注册表
我目前在 Windows 8.1 64 位上运行
如果可能有帮助,我将包含我目前正在处理的代码
import java.util.Scanner;
import java.text.NumberFormat;
/**
* Title: CarLoanUser
* Description:
* @author
* @version 1.0
*/
public class CarLoanUser {
/**
* @param args
*/
public static void main(String[] args) {
runWithConsole();
}//main(args)
public static void runWithConsole()
{
NumberFormat money = NumberFormat.getCurrencyInstance();
Scanner key = new Scanner(System.in);
CarLoanMethods user;
int numberOfPayments = 0;
double remainingAmount, remainingAmountInCalculation;
user = new CarLoanMethods();
System.out.print("What is the model? ");
user.setModel(key.nextLine());
System.out.print("What is the loan amount? ");
user.setLoanAmount(key.nextInt());
remainingAmountInCalculation = user.getLoanAmount();
System.out.print("What is the interest rate? ");
user.setInterestRate(key.nextInt());
System.out.print("What is the monthly payment? ");
user.setMonthlyPayment(key.nextInt());
user.calculateEverything();
System.out.printf("\n%10s%35s", "Car model: ", user.getModel());
System.out.printf("\n%14s%31s", "Amount to pay: ", money.format(user.getTotalPrice()));
System.out.printf("\n%33s%12s", "Total interest that will be paid: ", money.format(user.getTotalInterest()));
System.out.printf("\n%19s%26s", "Number of payments: ", user.getNumberOfPayments());
}//runWithConsole()
}//CarLoanUser class
以及方法类:
/**
* @author
*
*/
public class CarLoanMethods {
private String model;
private int loanAmount;
private int interestRate;
private int numberOfPayments = 0;
private double monthlyPayment;
private double interestTotal;
private double interest;
private double toBePaid;
public CarLoanMethods()
{
model = "Unknown";
loanAmount = 0;
interestRate = 0;
monthlyPayment = 0;
}//CarLoanMethods()
public CarLoanMethods(String userModel, int userLoan)
{
model = userModel;
loanAmount = userLoan;
interestRate = 0;
monthlyPayment = 0;
}//CarLoanMethods(String, int)
public CarLoanMethods(int userInternetRate, int userMonthlyPayment)
{
model = "Unknown";
loanAmount = 0;
interestRate = userInternetRate;
monthlyPayment = userMonthlyPayment;
}//CarLoanMethods(int, int)
public void setModel(String userModel)
{
model = userModel;
}//setModel(String)
public String getModel()
{
return model;
}//getModel()
public void setLoanAmount(int userLoan)
{
loanAmount = userLoan;
}//setLoanAmount(int)
public int getLoanAmount()
{
return loanAmount;
}//getLoanAmount()
public void setInterestRate(int userInterestRate)
{
interestRate = userInterestRate;
}//setInterestRate(int)
public int getInterestRate()
{
return interestRate;
}//getInterestRate()
public void setMonthlyPayment(double userMonthlyPayment)
{
monthlyPayment = userMonthlyPayment;
}//setMonthlyPayment(double)
public double getMonthlyPayment()
{
return monthlyPayment;
}//getMonthlyPayment()
public double getTotalInterest()
{
return interestTotal;
}//getTotalInterest()
public double getTotalPrice()
{
return interestTotal + loanAmount;
}//getTotalPrice
public int getNumberOfPayments()
{
return numberOfPayments;
}
public void calculateEverything()
{
double remainingAmountInCalculation = getMonthlyPayment();
while (remainingAmountInCalculation >= 0)
{
interest = remainingAmountInCalculation * ((interestRate / 100.0) / 12.0);
interest = Math.round(interest * 100.0) / 100.0;
remainingAmountInCalculation = (remainingAmountInCalculation + interest) - monthlyPayment;
interestTotal += interest;
++numberOfPayments;
}
}
}//CarLoanMethods
该程序应该按我的预期工作。我知道它需要一些工作,但是是的。
【问题讨论】: