No Java console output in Eclipse; works with PyDev - eclipse

I have both a Java and a PyDev project in one workspace. When I run the PyDev project (either the main script with Run > Run As > Python Run or its associated unit test with Python unit-test), the console output looks fine. However, when I switch to the Java project, open the main class, make sure the cursor focus is in the main class, and run it with Run > Run as > [my run config], no output shows up in the console, stdout or stderr. I've tried with Run/Debug > Console > Fixed width console checked and unchecked, similarly for Limit console output. "Allocate console" is check in [my run config].
I have tried redirecting output to a file in my run configuration, but the log file is empty after a run; thus, I suspect stdout/stderr are being trapped somewhere. I suspect that it is PyDev causing the issue because when I run the Java project, this exception reliably shows up about 6 times in the error log:
Launch shortcut 'org.python.pydev.debug.ui.launchShortcut.python.unittest' enablement expression caused exception. Shortcut was removed.
stacktrace:
org.eclipse.core.runtime.CoreException: No property tester contributes a property org.python.pydev.debug.ui.python_type to type class org.eclipse.ui.part.FileEditorInput
at org.eclipse.core.internal.expressions.TypeExtensionManager.getProperty(TypeExtensionManager.java:123)
at org.eclipse.core.internal.expressions.TestExpression.evaluate(TestExpression.java:96)
at org.eclipse.core.internal.expressions.CompositeExpression.evaluateOr(CompositeExpression.java:68)
at org.eclipse.core.internal.expressions.OrExpression.evaluate(OrExpression.java:21)
at org.eclipse.core.internal.expressions.CompositeExpression.evaluateAnd(CompositeExpression.java:53)
at org.eclipse.core.internal.expressions.AndExpression.evaluate(AndExpression.java:29)
(... and so on)
Additionally, printing from a Java program in a different workspace that only has Java projects works fine.
I tried uninstalling PyDev and restarting Eclipse, but I'm still having the same issue. I still have those errors after reinstalling PyDev, too.
Has anyone run into this issue before, or know of a way to fix it?

Well, I feel like an idiot; turns out, I had redirected stdout/err to a log file that I had long since forgotten about, and stuck somewhere difficult to find.

I ran into the same problem so I did some research. Seems like there was an old issue (2006-2008), but it was resolved by adding an option to the launch configurations to allocate a console. This is available from the Run -> Debug Configurations menu option, Common tab. Perhaps this is simply unchecked after the PyDev install?
If this is a new bug, there were two possible workarounds suggested:
Set up debug launch configuration that uses remote debugging instead of local debugging.
Use a buffered writer to System.out.
Here are the threads for reference:
Eclipse bug - https://bugs.eclipse.org/bugs/show_bug.cgi?id=122429
Workaround thread - java.io.Console support in Eclipse IDE

Related

Interactive console/Pydev console breaks completely on unhandled error

Eclipse Neon (4.6) with PyDev 5.1.2.
Run any python script with Pydev, break on something, and start playing in the normal console or the Pydev Debug console associated with the running script.
If you cause an exception, e.g. type 'test' (without the quotes) to reference a non-existent variable, after the traceback is printed, the console is unusable - you give it a statement, it thinks for a bit and then returns with no result.
In the Eclipse status bar it says 'PyDev Debug Console...Communication' (middle part is omitted, can't get that part of the UI to be long enough to see), but nothing else - i.e. it looks like the debugger dies when the exception happens.
I have used Pydev on and off for years, this is not a new thing for me but it is time I ask about it - is this normal behaviour?
Thanks for any help.
The problem was solved by creating a new workspace, installing the usual plugins and configuring as normal - suddenly the ipython session can cope with errors it raises.

Eclipse not noticing changes to eclipse.ini?

I have had a problem lately with jvisualvm not allowing me to take heap dumps and showing very little information at all. I believe this is my problem.
I made the suggested changes to eclipse.ini. It currently looks like this:
The line in question here is then line 19.
Now, when I check the configuration in Eclipse, the new option doesn't show up.
I have restarted Eclipse twice, both via File -> Restart and closing and re-opening, with no effect. Also, I have changed the order of the options in the file, with no effect.
What might cause this and can this be fixed somehow?
EDIT: I also tried closing Notepad++ and then restarting. No effect. type in the command prompt still shows the changes, so they are there.
I managed to solve it by running Eclipse in clean mode, as described here.
I ran Eclipse from the command prompt:
C:\Program Files (x86)\Eclipse>eclipse -clean
This can be done in other ways also, as seen the answer linked above.
At this point, the problem is solved. The rest of the steps are what happened.
I had to choose my workspace again, as the cache had been cleared.
Package Explorer failed to load.
After one more restart, everything worked fine.

How to have change debugger setting in Eclipse for a launch file

His,
I have been trying to find out why starting DevMode with Debugger from Eclipse was so slow and noticed in the list of processes on my machine the following line:
/usr/lib/jvm/jdk1.6.0_14/bin/java -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:47248 ...
Apparently the application is suspended to wait until the debugger is connected which takes about 2 minutes. I would like to set "suspend=n". Does anyone know where I could set this directive. The vm section in Eclipse launch configuration is empty and if I paste the updated debugger config there is a error telling that the values are entered twice.
As I understand it, Eclipse takes this config from somewhere and inserts it automatically when I run launch configurations in debugger mode.
Thanks
You can't remove that parameter and, if you could, it wouldn't make a difference. When you connect a new browser to the GWT OOPHM instance it has to compile the entire project for use in development mode. This is what takes time, not waiting for the debugger to attach.

Whats the shortcut to Debug in PyDev using Eclipse

The shortcut key is F11 to start debugging. But issue is that I have to be on that file and then hit F11 to start debugging.
Eg.
my file to launch the application is "launch.py" and "example.py".
example.py is open in the editor whereas launch.py is not.
Now, if I hit F11 it will try to launch the application using "example.py" and terminates due to error (as expected).
So then I have to open the "launch.py" in the editor and then hit F11 to start debugging the application.
Is there any neater way to configure the debugging, so that it starts the application in single hit/key?
Edit: example.py is some other file (some module). It does not launch the application.
As this PyDev Eclipse Tutorial suggests:
After the first run, if you type Ctrl+F11, the last file ran is re-run. Or, if you type just F11, a debug session is started with your last run. Let's test this...
Note: This behavior changed in Eclipse 3.3 -- but it's generally recommended to restore it in the preferences at: window > preferences > Run/Debug > Launching and set the Launch Operation to Always launch the previously launched application.
This tutorial will always consider this as the default option.
So, did you have this option selected?
If you have launch at least once launch.py, then you can re-launch it easily.
Although this isn't strictly an answer to what was asked initially, it might help someone looking here that had the same problem as me...
I'm a Java developer mainly, so have the Java view open almost all the time. However, sometimes I want to run some python file to test something (or just create a quick python script, and run it)...
In the Java editor, if the current class has a main(String[] args) method, I run it with (and popup the dialog to ask me what exactly I'd like to run in the middle)
alt+shift+x, j
Unfortunately, that doesn't work in the Python view, and I've not found a similar solution - it just asks me if I'd like to run it as a Java app... however, as the VonC says, you can run the last run thing (provided you've set the preferences accordingly) with
ctrl+f11
and this seems work well with python run configurations too.
But... What if the last thing I ran was a Java program, but I now want to run the active .py file? Previously, to run the .py file, I'd have to go digging through the buttons on the toolbar with the mouse, and I tend to prefer keyboard shortcuts...
Solution! So, finally I come to the actual useful bit of this answer - I just discovered by accident (typing Ivan's suggested shortcut, but missing!), it appears that
f9
will run the currently active python file.
Hope that helps someone get just that little bit faster...
I use CTRL+SHIFT+F9 to relaunch the previous debug configuration in Pydev.

Strange behaviour of created *.exe

Has anyone any idea why the resulting exe from a build comes with a console?
I've built an EXE and it shows up with the window it should (the right one), and a console window (the left one - obviously).
alt text http://img216.imageshack.us/img216/570/strangep.jpg
This behaviour is the same for the debug - exe and the release - exe.
When I start it from Eclipse the console window does not show up.
(Eclipse Galileo / MinGW / C)
Find the linker settings, and add the -mwindows switch.
you might look into this here surely answers why Eclipse is not opening your console window
There seems to be no way to get a java.io.Console object when running an application through Eclipse. A command-line console window is not opened with the application, as it is run as a background process (background to Eclipse?). Currently, there is no Eclipse plugin to handle this issue, mainly due to the fact that java.io.Console is a final class.
All you can really do is test the returned Console object for null and proceed from there.
as far as your console window popping is concerned, you might be using System.console in the application
Hope this Helps