Advertisement

Real time debugging with java in eclipse

Started by March 02, 2019 03:39 PM
11 comments, last by Gustavo_0 5 years, 6 months ago

Hi, so, I know it's possible to debug real time in eclipse, using java, but I don't know exactly the procedures of it. It seems I have to install some extensions or java libraries? I don't know, and I can't find much help googling to see what exactly I have to do. Thanks.

Let me know if this helps:

https://www.eclipse.org/community/eclipse_newsletter/2017/june/article1.php

I personally haven't used Eclipse in years... but this should be what you're looking for.

Programmer and 3D Artist

Advertisement

Ok so here's the code snippet:

public class Test extends Canvas implements Runnable{
    
    private static final long serialVersionUID = 1L;
    public static int WIDTH = 160;
    public static int HEIGHT = 120;
    public static int SCALE = 3;

    public Test() {
        this.setPreferredSize(new Dimension(WIDTH*SCALE,HEIGHT*SCALE));
    }

    public static void main(String[] args) {
        Test game = new Test();
        JFrame frame = new JFrame("Pong");
        frame.setResizable(false);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.add(game);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        
        new Thread(game).start();
    }
    
    public void run() {
        while(true) {
            System.out.println("test");
            try {
                Thread.sleep(1000/60);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

 

I wanted to change the argument in prinltn and it show in real time. So I remembered that this feature is called hotswap, but it isn't working, and I don't know if I can configure Eclipse for it

Also searching for "hava hotswap" on google gives this result:

http://hotswapagent.org/

It says it is a "Java unlimited runtime class and resource redefinition." and I'm not sure what that means. It also says:

"In contrast to standard Java, where the hotswap is limited to in-body code changes, the DCEVM + HotswapAgent allow following code changes:"

So what would be this difference, of hotswapping in standard java, in-body changes?

Have you looked into JRebel? https://zeroturnaround.com/software/jrebel/

Programmer and 3D Artist

Don't know exactly what you mean with "real-time", but I make Eclipse applications, and do "RMB on project -> debug -> as Eclipse application". Then it starts a sub-eclipse with the application (ie everything in your workspace constructed), and you can start the application to debug in the sub-eclipse. If you set a break point in your main eclipse and it gets hit by the code in the sub-eclipse, the main eclipse will switch to the debugger, where you can debug the problem, single-step etc.

You can also change code in the main eclipse, and it will attempt to perform that change in the sub-eclipse too. Depending where you made the change, it works, or it has to restart the sub-eclipse.

How you do that? I didn't understand the "rmb on project"

Advertisement
1 hour ago, Gustavo_0 said:

How you do that? I didn't understand the "rmb on project"

Did you not check the link I posted? It shows how to use the debugger....

Programmer and 3D Artist

Yeah I checked it, but what I want, is to change the code, and don't need to restart the application for the results to change, I din't understand what "rmb on project" meant.

I will try to install this though:

http://hotswapagent.org/

And I will also try jdk 11, so I will see how it goes

Also I'm gonna try JRebel and see how it goes

RMB means Right Mouse Button.

Did you check out JRebel, doesn't this do what you want?

Programmer and 3D Artist

Aaahhh rmb is right mouse button, oh my, sorry

Yeah and JRebel does it, I think there is another ways to do it though, and JRebel is paid so there is that

This topic is closed to new replies.

Advertisement