简体   繁体   中英

How can I get the Eclipse console to print messages from a DLL?

I've been developing code for a microcontroller and a GUI to interact with it. I've created DLLs to allow communication between the microcontroller and GUI over CAN or USB.

I'm currently creating the GUI in Java using Eclipse, and I'd like to be able to see printf messages from the DLL in the Eclipse console.

The strange thing is, I have two Eclipse projects that use the USB messaging DLL and that seem to have practically identical configuration settings, but in one project I'm able to see the printf messages from the DLL after I've terminated the Java application, and in the other I don't get back anything at all.

I'm wondering why that might be the case and if there's any way to be able to toggle message feedback from DLLs on and off in either application.

For comparison:

Project 1

在此处输入图片说明

Project 2

在此处输入图片说明

The Eclipse console play the role of the standard streams (output, error, input) after starting a process inside Eclipse. Most of the time, these will be Java processes when you run your main classes of your projects.

So, if you simply load a DLL as a native library inside a Java program, this will become part of the process and all printing on the standard streams should be redirected to the visible console.

On the other hand, if you start another process within your program you must redirect those streams yourself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM