有没有办法让捆绑包在OSGi输出流中打印字符串?我是说像System.out.println("String");一样。取而代之的是,我希望bundle在该流中打印它的字符串。
public void start(BundleContext bundleContext) throws Exception {
Activator.context = bundleContext;
System.out.println("Hello World!"); // I want to print this string in osgi console.
}您看,如果我运行OSGi框架,它将在Java Console中打印其对命令的响应,System.out也会在其中打印。
但是我的问题是,我要在JTextArea中打印它的输出,所以我希望bundle也能够在那里打印(在OSGi控制台输出流中打印它的字符串)。在这种情况下,我需要一种访问OSGi输出流的方法。
发布于 2011-10-12 17:01:14
如果我没理解错的话,您的JTextArea充当控制台或控制台输出的视图。因此,我建议只在该JTextArea中显示System.out流。下面是一个实现这一点的示例:http://unserializableone.blogspot.com/2009/01/redirecting-systemout-and-systemerr-to.html
https://stackoverflow.com/questions/7728965
复制相似问题