2014-11-21 216 views
1

我已经使用了Eclipse很长一段时间,但是最近我刚刚发现了一个错误,它现在真的让我感到困扰,因为我无法使用调试器。我可以正常运行我的程序,但不是调试器。这是我所得到的,当我尝试用调试器中运行:无法使用调试器(无法连接到虚拟机)

'Launching CarLoanUser' has encountered a problem Cannot connect to VM Cannot connect to VM com.sun.jdi.connect.TransportTimeoutException

,并在控制台:

FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197) ERROR: transport error 202: connect failed: Permission denied ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510) JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [debugInit.c:750]

我已经尝试了很多东西与它有关:

  • 重新启动Eclipse
  • 重新启动我的电脑
  • 尝试其他代码我自己的
  • 重新安装的Eclipse(露娜)
  • 删除蚀(月亮)和与Eclipse的Java EE更换(开普勒)
  • 反悔的Eclipse(月神)
  • 卸载所有Java的安装实例的Java 8
  • 卸载Java的8和安装Java 7(所有Java安装与64位installator)
  • 清洁

我目前在Windows上运行8.1与CCleaner的登记中心的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 

程序应该工作,我想要它做的。我知道它需要一些工作,但是。

回答

0

This解决方案说它可能是因为调试器想要使用它的端口。

我想它也可能是一个防火墙阻止它,确保这不是问题。

1

我一直有这个问题一段时间。 我真的找不到一个明确的解决方案(一个可以使其100%的时间工作),但至少我可以调试。

首先您需要检查javaw是否已经在使用该端口。要在Windows中执行此操作,您有两种选择:

  • 转到任务管理器 - >资源监视器 - >网络。

还有检查侦听端口(javaw进程使用5001和8080)

  • 运行 - > CMD - >然后键入:netstat的-n

您将看到端口5001和8080在聆听。

如果看到打开的端口不打算调试。正常运行应用程序,停止它,等待几秒钟,然后再次检查。

如果您在聆听时没有看到它们,那么您可以进行调试,但不要通过菜单进行调试;去运行 - >调试配置 - >并从那里按调试。

我知道这不是一个明确的解决方案(而且这个问题已经有1年了),但对我来说足够让我调试并继续开发。

+0

注意:如果防火墙阻止或不阻止,我已经检查了几次。我肯定需要检查资源监视器,并在调试之前等待javaw实例死掉。出于某种原因编译杀死当前进程而不是调试。 – Johns 2015-12-23 13:06:52

相关问题