`
leonzhx
  • 浏览: 796296 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Run Application in debug mode

    博客分类:
  • Java
阅读更多

Q: I use the Eclipse IDE to develop, compile, and run my Java projects. Today, I'm trying to use the java.io.Console class to manage output and, more importantly, user input.

The problem is that System.Console() returns null when an application is run "through" Eclipse. Eclipse run the program on a background process, rather than a top-level process with the console window we're familiar with.

Is there a way to force Eclipse to run the program as a top level process, or at least create a Console that the JVM will recognize? Otherwise, I'm forced to jar the project up and run on a command-line environment external to Eclipse.

 

 

A: I assume you want to be able to use step-through debugging from Eclipse. You can just run the classes externally by setting the built classes in the bin directories on the JRE classpath.

java -cp workspace\p1\bin;workspace\p2\bin foo.Main

You can debug using the remote debugger and taking advantage of the class files built in your project.

In this example, the Eclipse project structure looks like this:

workspace\project\
                 \.classpath
                 \.project
                 \debug.bat
                 \bin\Main.class
                 \src\Main.java

1. Start the JVM Console in Debug Mode

debug.bat is a Windows batch file that should be run externally from a cmd.exe console.

@ECHO OFF
SET A_PORT=8787
SET A_DBG=-Xdebug-Xnoagent-Xrunjdwp:transport=dt_socket,address=%A_PORT%,server=y,suspend=y
java.exe %A_DBG%-cp .\bin Main

In the arguments, the debug port has been set to 8787. The suspend=y argument tells the JVM to wait until the debugger attaches.

2. Create a Debug Launch Configuration

In Eclipse, open the Debug dialog (Run > Open Debug Dialog...) and create a new Remote Java Application configuration with the following settings:

  • Project: your project name
  • Connection Type: Standard (Socket Attach)
  • Host: localhost
  • Port: 8787

3. Debugging

So, all you have to do any time you want to debug the app is:

  • set a break point
  • launch the batch file in a console
  • launch the debug configuration
分享到:
评论

相关推荐

    BURNINTEST--硬件检测工具

    - A printer to run the printer test, set-up as the default printer in Windows. - A CD ROM + 1 Music CD or Data CD to run the CD test. - A CD-RW to run the CD burn test. - A network connection and the ...

    kinectsample

    If you want the project to work in debug mode you would need to: 1) Copy the Data directory from the bin into the bindbg directory. 2) Copy cg.dll from the bin into the bindbg directory. 3) Copy all ...

    jscoin-miner-pool

    jscoin节点池管理器 描述 简单的服务器,管理所有启动的挖掘节点,收集所有启动的节点,并将当前活动节点的列表发送给所有人 ... # run server in development mode npm run dev # build documentation npm run doc #

    apktool documentation

    InfoIn order to run a rebuilt application. You must resign the application. Android documentation can help with this. Frameworks Frameworks can be installed either from if or install-framework, in ...

    EurekaLog_7.5.0.0_Enterprise

    7)....Added: Streaming unpacked debug info into temporal files instead of memory - this greatly reduces run-time application memory usage at cost of slightly slower exception processing. This also ...

    UE(官方下载)

    Sum Column/Selection in Column Mode This power tip demonstrates how to calculate the sum from a column of numeric data. Column mode How to use the features of UltraEdit's powerful column mode Advanced...

    Bloodshed Dev-C++

    * Project manager and debugging window (in Debug tab) can now be trasnformed into floating windows. * Added "Add Library" button in Project Options * Bug fixes Version 4.9.6.9 * Implemented search in...

    FastReport.v4.15 for.Delphi.BCB.Full.Source企业版含ClientServer中文修正版支持D4-XE5

    + [enterprise] added property "Scheduler" - "Debug" in server configuration - enable writing of debug info in scheduler log + [enterprise] added property "Scheduler" - "StudioPath" in server ...

    BCGControlBarPro.v12.00

    The Ribbon bar Application ("main") Button can display a text label instead of icon in the "scenic" mode (usually "File" in English language UI). The following new methods were added to the ...

    Bochs - The cross platform IA-32 (x86) emulator

    [3009767] guest RFLAGS.IF blocks externel interrupt in VMX guest mode [2964655] VMX not enabled in MSR IA32_FEATURE_CONTROL [3005865] IDT show bug [3001637] CMOS MAP register meaning error ...

    stm32f411ce.pdf

    – Stop (Flash in Stop mode, fast wakeup time): 42 µA Typ @ 25C; 65 µA max @25 °C – Stop (Flash in Deep power down mode, slow wakeup time): down to 9 µA @ 25 °C; 28 µA max @25 °C – Standby: ...

    acpi控制笔记本风扇转速

    The debug version of the code includes the debug output trace mechanism and has a much larger code and data size. Previous Release: Non-Debug Version: 78.1K Code, 17.1K Data, 95.2K Total Debug ...

    Turbo C++ 3.0[DISK]

    For instance, if you run MAKE on a file which in turn calls MAKE again, you will get a sharing violation. In this specific case, you can call the real mode version, MAKER, within the given makefile, ...

    ICS delphixe10源码版

    .\Samples\delphi\BroswerDemo Delphi Win32/Win64 Web Browser sample application (all Delphi versions) .\Samples\delphi\BroswerDemo\Resources Resource file, web pages and movie linked into browser demo ...

    Turbo C++ 3.00[DISK]

    For instance, if you run MAKE on a file which in turn calls MAKE again, you will get a sharing violation. In this specific case, you can call the real mode version, MAKER, within the given makefile, ...

    google api php client

    However, the libraries are considered complete and are in maintenance mode. This means that we will address critical bugs and security issues but will not add any new features. ## Google Cloud ...

    MS-DOS 5.0

    5.1 DOS Applications in Windows Enhanced Mode 5.2 EMM386.EXE Location 5.3 WINA20.386 File 5.4 Windows 3.0 Enhanced Debug Version 5.5 Windows 2.03 5.6 Windows/286 2.1 5.7 Windows 386 and the ...

Global site tag (gtag.js) - Google Analytics