How to Grab Eclipse Console Output Painlessly

Use this guide to grab eclipse console output effortlessly. After reading it, you’ll be able to grab eclipse console output successfully.

But before we dive into it, let’s start by answering this crucial question:

What is the Console in Eclipse?

The Console in Eclipse is what will enable you to view the output of the utilities invoked when building a project or the program’s output when you run or debug running the application.

Typically, you will follow these easy steps to view the output: Click Window > Preferences. Expand C/C++ and Build, then click Console. If you want to display information on the latest project only, use the “Always clear console before building check box” option.

Optimize Each Line Of the Eclipse Output

In your plugin, if you want to do something with each line of your eclipse output console, for example, write that line to a file or parse it before sending it to your custom eclipse view, you should create a class that implements IConsoleLineTracker, and you should add this extension point to your plugin.xml.

[img_assist|nid=1032|title=|desc=The steps are explained well here…|link=none|align=none|width=256|height=192]

Now, suppose your class implementing IConsoleLineTracker is this:

public class LogTracker implements IConsoleLineTracker {

    private IConsole m_console;
            
    public void dispose() {        
        
    }

    public void init(IConsole console) {        
        m_console = console;        
    }
    
    public void lineAppended(IRegion region) {
        try {
            String line = m_console.getDocument().get(region.getOffset(), region.getLength());
               
             // DO SOMETHING WITH THAT LINE
        } catch (BadLocationException e) {
            WrCheck.logError(e);
        }
    }
}

Copy the console output in Eclipse

The best method you can use to copy a console is to tell Eclipse to save console output to a file. To do this, you need to go to Run → Debug Configurations on the Eclipse menu. Once you Debug Configurations successfully, then navigate under the Standard Input and Output section, click on the checkbox next to File: and choose the name of the output file to use.

Get the full console in Eclipse

Are you trying to get full console in Eclipse? The good news is it’s possible to get it.
  • All you need to do is go to Windows –>
  • Preferences –> Run/Debug –>
  • Console and then unchecking “Limit Console Output” which is ON by default.
  • This works on STS any version too. This would help print complete console output.
  • For a Mac, it is Eclipse > Preferences > Run/Debug > Console.

View the console log in Eclipse

If you want to view the console login to Eclipse:
  • You need to go to Run -> Debug Configurations on the Eclipse menu.
  • Then, under the “Standard Input and Output” section,
  • Click on the checkbox next to “File:”, and choose the name of the output file to use.
  • If you check “Append” underneath, console output will be appended to the output file.

How do I save data on the console?

There will be times when you’ll need to save data on the console. To do this, all you need to do is right-click > go to Save button, which is in the Console panel. It will allow you to save the logged messages to a file.
In a situation where you have an object logged, then you can use the following steps:
  • Right-click on the object on the console and click Store as a global variable.
  • The output will be visible as “temp1.type in console”. Copy (temp1),
  • And paste it to your favorite text editor

Install a detached console in Eclipse

Want to attach the console to the main eclipse window? Follow these easy steps:
  • Click Window->Perspective-> then go to Reset Perspective to detach it.

  • EFCARDZ TREND REPORTS WEBINARS ZONES

  • DZone > Performance Zone > Remotely Debugging an Eclipse Plugin

Upgrade Eclipse

Follow the instructions below to upgrade Eclipse:

  • On the toolbar, navigate to Window > Install New Software. Click on Add and add the following URL for the latest build of Eclipse: https://download.eclipse.org/releases/latest.

  • Alternatively, you could add the specific build of Eclipse you want from https://download.eclipse.org/releases/ such as: https://download.eclipse.org/releases/photon/

  • or go to https://download.eclipse.org/releases/2019-09/.

  • Once the site is added to Eclipse, you can now proceed with the upgrade by navigating to Window > Help > Check for Updates.

  • This basically goes through all the sites under Window > Preferences > Install/Update > Available Software Sites and gathers updated details from the ones that are selected.

You should be able to see a pop-up listing the various plugins/tools that require an update. You have the option to select the ones that you need, or you can leave them as is. Then, click Next. Click Next after reviewing the details. You should now see the review license page. Click on the radio button “I accept….” and click Finish.

Remotely Debugging an Eclipse Plugin

The Eclipse plugin can be debugged from inside the IDE while in the development phase, but once the plugin is installed in the IDE, we need to debug it remotely for bug resolution. In this quick tutorial, I’m going to explain how to debug an Eclipse plugin remotely.

Plugin Project

Let’s suppose we have developed our simple Hello World plugin and installed it in our IDE. Now, to debug the plugin remotely, please follow the steps below.

Step 1

Open the first instance of Eclipse IDE pointing to the workspace where your Hello World plugin project is located.

Step 2

Navigate to the eclipse.ini file of your IDE. Here is a screenshot of the location of the file in macOS.

Now add the following JVM arguments to the file:

1

-vmargs

2

-Xdebug

3

-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044

Step 3

Now, open another instance of the Eclipse IDE (on macOS, use the command open -a -n Eclipse in the terminal). This instance will point to a workspace different from the one which contains the Hello World plugin project.

Step 4

Now, in the workspace containing the Hello World plugin project, make the following remote debug configurations/; Navigate Run -> Debug Configurations -> Remote Java Application.

Then hit the debug button. Also, do not forget to put break-points in the code of the Hello World plugin to be debugged.

Step 5

In the other workspace (which does not contain the Hello World plugin), try to use the Hello World plugin and it will be remotely debugged in the other instance of Eclipse.

Conclusion

There are Eclipse-based IDEs that have a powerful feature to make ‘variants’ of the same projects. Use the to Build Configurations, which are a powerful feature in Eclipse.

They will allow you to make ‘variants’ of a project. The project will share the common things, and you can simply tweak things one way or the other for example to produce a ‘release’ or a ‘debug’ binary of my application without duplicating the project.

.

Leave a Comment