does netbeans have something like Eclipse Debug display view - java

does netbeans have something like Eclipse Debug display view?
I love the interactive window for trying out Java code in Eclipse debug mode, and it's mentioned in this post:
Is there any Python-like interactive console for Java?
Just wondering if I can get the same in netbeans

There is a menu option: Debug - Evaluate Expression...
And also a shortcut: Ctrl+F9 (in Windows)
You can see an explanation at How to Evaluate Code

There isn't an interactive window for debugging quite like Eclipse, although you can set up breakpoints in the program while debugging to follow the step by step route in which the program executes. Have you looked at the NetBeans site? http://netbeans.org/features/java/debugger.html

While debugging, press ctrl+shift+I to evaluate an expression. In the "Evaluate Expression" window you can do the same as in eclipse's display window.

Related

Execute commands/code on the fly during debug mode in Eclipse

On Visual Studio while developing using ASP.NET with C# or VB, I used to be able to execute code or call some APIs on the fly using the console or debug window.
I am asking if this can be done using Eclipse while debugging JSP or Java classes, and how?
Tarek
The Display view in Eclipse is used to do this. You can open using the shortcut Ctrl+3 and search for Display.
There, you can inspect, evaluate expressions and execute code during the current debug context. To execute code in the view for instance, you would select the code that is typed in the view and press Ctrl+U (the same can be done by right-clicking on the selection and clicking on the appropriate option from the context menu).

Breakpoints and step by step debug in Java?

Sorry for the strange name of my question. I don't know how to look for this because I don't know how these things are called.
There's a features in Visual Studio at least where you can click on the left of the code and set a starting point which is a big red dot. Then you run the program and you can trace the steps by pressing f8 or f5 (different f's really) and you see the variable values on each step etc. I find it extremely useful because I can see where an error occurs and how the program behaves.
I have no idea what this is called and I want to ask is there such a thing in NetBeans IDE 8.0.2 or jGrasp or any java compiler?
Sorry if anything sounds stupid, I'm kind of a newbie.
Thank you all
Most IDEs have debugging functionality built in.
In Netbeans, you can easily add/remove a break point by simply clicking the line number on right side of the source editor (you can also do via the editor popup menu)
You start the debugger through F5 (ShiftF5 for debug the current file) or via the debug icon on the toolbar
You can use F8 to step over the command/method call, F7 to step into a method. You can resume running the program using F5 while the debugger is running.
See Debugger and Profiler and Using the Visual Debugger in NetBeans IDE for more details
Finding how to do this in your IDE is pretty easy, see the other answers.
What is a bit more difficult is debugging an external (and/or) remote Java program in your IDE. Here it is how to do that with Eclipse: http://www.ibm.com/developerworks/library/os-eclipse-javadebug/. I guess other IDEs are similar. If you test via Maven/Surefire, you have a simple flag to do the same: http://maven.apache.org/surefire/maven-surefire-plugin/examples/debugging.html

'Immediate' window for IntelliJ

I'm using IntelliJ 9 and I'm curious if there is any IntelliJ equivalent of the Visual Studio 'immediate' debug window. There is selecting the desired expression in the editor, then ALT-F8 to evaluate the expression, but I'd like to be able to write code in a window that interacts with what I am currently debugging (if that's even possible).
Having breakpoints that log messages to the console is helpful, but I'd like to do more than that if I can.
Intellij IDEA's Expression Evaluation dialog has a button to enable Code Fragment Mode, which permits multi-statement evaluations. (I'm using version 9.0.2 of the Ultimate Edition.)
Same as #Noel answer, but some more details. First of all, Expression Evaluation (ALT + F8) can be enabled only in debug mode.
IntelliJ IDEA 13 Community Edition, Windows:
Go to Debug mode and run the application
Go to Evaluate Expression:
or right click in the editor area:
Go to Code Fragment Mode
Type your statements and click on Evaluate
FYI for anyone looking for this in 2019: I tried to do this in IntelliJ IDEA 2019.1 (Ultimate Edition) but couldn't find Code Fragment Mode button in the Expression Evaluation Dialog.
As documented here: It is now the tiny two arrows pointing away from each other diagonally at the end of the expression box.
You can write code in alt-f8.. but you have to do it only 1 line at a time. If you do a return, your code will return when you hit next (I think). It isn't ideal though...

How to execute some function in eclipse while debugging a java program?

Like firebug for debugging javascript,
is there such a feature in eclipse? or do I need a plugin?
Use the Display view, or a bit quicker: highlight the code you want to run and right-click/Execute or Ctrl+U.
You can use the Display view to execute commands while debugging. You can find this in Window -> Show View -> Display
Select the line and press ctrl+shift+D or ctrl+shift+I
This will give the result in a popup.
Use the debug shell! Coming from node, I was pretty used to being able to mess with my env variables at any time using node --inspect in chrome, and so it was imperative for me to find the same experience in eclipse without having to use JDB.
To open the debug shell, go to Window → Show View → Debug Shell
After you write the code you wish to run, simply highlight it, right click, and execute (⌘U also works)
I believe that what you're looking for are "watch expressions". Just mark the piece of code in the source code view, right-click and select "Watch".
I'm currently using Eclipse Photon (v4.8.0).
Eclipse changed the "Display" View name to "Debug Shell View".
Here, you can execute commands on-the-fly.
you can use the 'Display' view to evaluate expressions in eclipse.
Look under the debug list of views. It is a standard par part of the java tooling so you don't need a plugin
Complementing all the amazing answers, for mac users is cmd + D
You can also create a scrapbook page (a .jpage) file and type your code in there. Then click run. It looked slightly more convenient when I tried it.
Like others say, you use the Display view. But for some variants of Eclipse, it may be named differently. For instance, if you are using Spring Tool Suite as your Eclipse, the View name corresponding to Display view is Debug Shell.

How do you debug a Rails application?

Is it possible to debug a Rails application in a similar way to a Java application - setting breakpoints and stepping into the code?
What are the best tools for this?
I have a hybrid Java/Ruby on Rails application which I can run in Eclipse or Netbeans.
I would like to step into some code in this app and try to figure out the cause of a problem I'm having.
In Eclipse if I set a breakpoint in my blog_controller and then choose the 'Debug' button, it seems to use the ruby-debug-ide gem to execute the code but I get this unhelpful output and no option to step into any source:
Fast Debugger (ruby-debug-ide 0.4.5) listens on localhost:56726
./war/WEB-INF/app/controllers/blog_controller.rb:1
C:/Ruby18/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.5/lib/ruby-debug.rb:101:in `debug_load'
C:/Ruby18/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.5/lib/ruby-debug.rb:101:in `debug_program'
C:/Ruby18/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.5/bin/rdebug-ide:82
C:/Ruby18/bin/rdebug-ide:19:in `load'
C:/Ruby18/bin/rdebug-ide:19
Uncaught exception: uninitialized constant ApplicationController
I'm not sure if I'm doing something wrong or if this is all I can expect.
The debugger I use the most is the ruby-debug gem, which is a gdb-esque command line debugger. Once you learn a few commands it is very quick and effective, and provides you with some handy features like being able to fire up irb in the context of your program and make on-the-fly changes.
And being command line based it comes in handy when you need to debug a on a remote server.
You can expect more. I have used Aptana's RadRails version of Eclipse to debug a Rails app as you describe--setting breakpoints and stepping through the code.
You may be doing something wrong. It looks as if it is trying to debug an individual controller file, rather than debugging the Rails app. When I try to execute a controller file from the command line, I get a similar message:
C:\workspace\myapp\app\controllers>ruby users_controller.rb
users_controller.rb:1: uninitialized constant ApplicationController (NameError)
In Aptana RadRails, I choose Run > Debug As > Ruby Application to debug the app.
For the vim users I strongly recomend looking into the vim-ruby-debugger, which fits in great with Tim Pope's rails.vim scripts.
It gives you a handy :Rdebugger command, allows you to set breakpoints and open a split window to display variable values.
maybe not relevant, but I wanted to post somewhere: got the error: "undefined method `run_init_script' for Debugger:Module" running the debugger in rails 2.3.2. Did a sudo gem install ruby-debug and the problem went away.
I'd recommend just setting up breakpoints (I actually just puts to console) for 99% of debugging with RoR - this method is simple and usable across any IDE, so you never need to learn how a new debugger works.
Actually, I had the same problem with Aptana. Run > Debug As > Ruby Application just doesn't work. I finally made the debugger work by going to the Servers tab, and then start the server in debug mode. After that, set some breakpoints and trigger the corresponding action. Hope this helps.
Debugging? That's just knowing where to look in the case of Ruby (and by extension, Rails) most of the time.
The problem in this case is that you probably still have your ApplicationController called application.rb where it should be renamed to application_controller.rb.
Debuggin in rails is simple if you know how to read the error stacktrace!! But if you need to explicitly watch out the values during the runtime then u can use the rails breakpointer.Below is the link to how-to on breakpointer ..hope this helps!!!
http://destiney.com/blog/rails-breakpointer
I can't speak for Eclipse (never worked well for me) or Aptana (not tried) but from experience I can say that both NetBeans and RubyMine will do what you want. I both cases you should probably make sure that the ruby-debug-base and ruby-debug-ide gems are up-to-date: RubyMine in particular didn't work for me until that was done.

Categories