2014-11-21 178 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

相關問題