3

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?

Eric W.
  • 814
  • 1
  • 8
  • 18
  • Can you reproduce this with other java apps? Either way, can you append some code to show how you're writing to the console (or System.out)? – Chris Gerken Aug 31 '12 at 18:32
  • I am just doing the usual System.out.println(). It used to print fine, but since adding a PyDev project to the same workspace, it does not work. When I switch workspaces (to one without a PyDev project), the console works fine in Java apps. – Eric W. Aug 31 '12 at 20:20
  • So you should be able to close the PyDev project and have the java app run? If so I'll have to bow out of this as I have no idea about what PyDev is and does. – Chris Gerken Aug 31 '12 at 20:36
  • The problem persists with all PyDev projects and the PyDev perspective closed. – Eric W. Aug 31 '12 at 21:16
  • Eclipse can have multiple consoles... are you looking at the right console? Pydev has its own console, Java has its own console. –  Sep 01 '12 at 00:44
  • on top right corner of console view, there's an icon right near minimize button, click it will show you a list of all active consoles, for example, mine shows "Java stack trace console", "CVS", "Pydev console", "Scala console", "Host OSGi console", etc –  Sep 01 '12 at 00:52
  • It is displaying the correct console, and I am using the right launch configuration. – Eric W. Sep 01 '12 at 19:52

2 Answers2

1

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.

Eric W.
  • 814
  • 1
  • 8
  • 18
  • Just curious... was that redirection a PyDev thing or an Eclipse thing? Was the missing Java output there? – Chris Gerken Sep 04 '12 at 17:37
  • 1
    It was a me thing. Entirely my fault. Oops. I found all of the log files I had been creating, and the output was getting redirected there successfully. – Eric W. Sep 04 '12 at 17:44
0

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

Community
  • 1
  • 1
saarp
  • 1,931
  • 1
  • 15
  • 28
  • The console is allocated. I also tried redirecting output to a log file, and the log file ends up empty. That makes me suspect that stdout/stderr is getting intercepted somewhere along the way. – Eric W. Sep 01 '12 at 19:53
  • Hrm. Grasping at straws here, but I took a look at the PyDev code for org.python.pydev.debug.ui.PythonTypePropertyTester. Could you try naming your log file with a .py or .pyw extension? It looks like the code is expecting the output file to be a Python file. – saarp Sep 01 '12 at 20:08