当前位置: 首页 > 知识库问答 >
问题:

无法使用调试器(无法连接到虚拟机)

赵驰
2023-03-14

我已经使用Eclipse很长一段时间了,但是我最近遇到了一个错误,这个错误现在真的困扰着我,因为我无法使用调试器。我可以正常运行我的程序,但不能运行调试器。这是我尝试使用调试器运行时得到的:

启动CarLoanUser时遇到问题无法连接到虚拟机无法连接到虚拟机com . sun . jdi . connect . transporttimeoutexception

在控制台中:

本机方法中的致命错误:JDWP未初始化任何传输,jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)错误:传输错误202:连接失败:权限被拒绝错误:JDWPTransport dt_socket未能初始化,TRANSPORT_nit(510)JDWP退出错误AGENT_ERROR_TRANSPORT_ INIT(1907):未初始化传输[debugInit.c:750]

我已经尝试了很多关于它的事情:

    < li >重新启动Eclipse < li >重新启动我的计算机 < li >尝试我拥有的另一个代码 < li >重新安装Eclipse (Luna) < li >删除Eclipse (Luna)并替换为Eclipse Java EE (Kepler) < li >返回Eclipse (Luna) < li >卸载所有Java实例并安装Java 8 < li >卸载Java 8并安装Java 7(所有Java安装都带有64位安装程序) < li >用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

该计划应该按照我的预期工作。我知道它需要一些工作,但是是的。

共有2个答案

阙繁
2023-03-14

这个解决方案说这可能是因为调试器想要使用的端口被占用了。

我认为它也可能是防火墙阻止它,确保这不是问题所在。

乌翰学
2023-03-14

我有这个问题已经有一段时间了。我真的找不到一个确定的解决方案(一个能让它100%工作的方案),但至少我可以调试。

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

  • 转到任务管理器 -

并检查监听端口(javaw使用5001和8080)

  • 跑-

你会看到监听端口5001和8080。

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

如果你在听的时候没有看到它们,那么你可以调试,但是不要通过菜单来调试;去跑步-

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

 类似资料:
  • 有人遇到过这样的问题吗。拥有Azure Functions应用程序(使用beta-2插件版本)。应用程序启动后,我收到一个错误,VSCode未能附加以删除调试对象VM。原因:连接被拒绝。 我已经安装了带有以下插件的VSCode:ms azuretools。vscode azurefunctions,vscjava。vscode java调试,vscjava。vscode java包,vscjava

  • 这是mysql连接php脚本。它不断地显示出它的错误 警告:mysqli_connect():(HY000/1045):用户'user'@'localhost'(使用密码:YES)在第6行的C:\xampp\htdocs\index.php访问被拒绝 注意:尝试在第7行连接成功的C:\xampp\htdocs\index.php中获取非对象的属性 我听不懂,请帮帮我好吗?

  • 首先,我知道有很多类似的问题,但我所看到的似乎都不能解决我的设置(我发现的任何解决方案都不管用)。所以请容忍我。。。 我的服务器主机名是IP地址,而不是域名(即URL看起来像:) 我的服务器有一个真正的证书(即,没有自签名) 我的应用程序的plist条目字典为空(没有任何例外-出厂设置ATS) 这是生产代码,我不能禁用ATS(我也不认为我可以,因为例外只适用于显式域名,而不是IP地址) (iOS9

  • 问题内容: 我正在尝试获取一些信息,但我的应用程序崩溃并显示以下消息: 这是代码: 这是一个纯课。的哪个调用不包含this 。我做错了吗?应始终位于内吗? 根据要求整体: 问题答案: 改成 您为布局充气。视图属于膨胀的布局。因此,使用view对象在中初始化视图 片段由活动主持 您可以在视图中使用和初始化 还在中初始化TextView 。由于Asynctask是一个内部类,因此您可以在那里更新ui

  • 我想尝试一下XDebug3.0.0RC1,以了解它发生了什么变化以及带来的新特性。我还使用了最新的PhpStorm 2020.3 EAP,它支持XDebug3,不需要主要配置。下面是调试器的PhpStorm配置: 下面是我为XDebug3尝试的配置: 我还尝试完全不添加设置,但仍然失败。 null 注意:我已经在这里应用了Xdebug开发人员提供的解决方案。

  • 我已经使用Genymotion大约一个月了,而且效果很好。然而,在过去的一周里,我一直收到这个错误,不管我的设置是什么: “无法连接到虚拟设备!Genymotion现在将停止。请检查VirtualBox网络配置。” 和更多信息的链接:https://cloud.genymotion.com/page/faq/#collable-nostart 我怎么解决这个?问题是模拟器以前工作过,现在不工作了。