-3

I'd like to print the HTML link in Eclipse console by using System.out.println.

When I use System.out.println("<a href=\"http://www.google.com\">whatever</a>");

it prints the string and not a link that I can click on.


Edit
I'm creating JUnit HTML report using Ant. It contains all output created by System.out.println in the browser. I want to pass a link constructed from within a program.

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
Vladimir
  • 630
  • 3
  • 12
  • 26
  • 5
    Why do you think that would make a clickable area in Eclipse's (or any) output console/device? – Sotirios Delimanolis Nov 09 '14 at 19:01
  • 6
    Text by itself can never magically become a link by itself unless that text is parsed by something (such as a browser) that **makes** it a link. What you are trying to do is magic, not coding. – Hovercraft Full Of Eels Nov 09 '14 at 19:01
  • Just to give something constructive and steer you away from thinking about sysout and clickable links, see this thread: http://stackoverflow.com/questions/527719/how-to-add-hyperlink-in-jlabel – mattias Nov 09 '14 at 19:05
  • I'm creating JUnit HTML report using Ant. It contains all output created by System.out.println in the browser. I want to pass a link constructed from within a program. – Vladimir Nov 09 '14 at 19:06
  • 1
    This was kinda not mentioned in your original problem statement. Consider rewriting your issue and include _anything_ you feel is worth sharing. – mattias Nov 09 '14 at 19:07

3 Answers3

0

You are printing to the standard output stream. If you can't click on the the printed HTML link, it means the standard output of your system does not support HTML and treats it as a string. (usually it just displays on the screen)

Up to now, I do not know about a system, which could have the standard output with such a feature. See: https://docs.oracle.com/javase/7/docs/api/java/lang/System.html#out

Eclipse console has no support for it, but maybe you can write a plugin.

EDIT:

JUnit HTML report will take the output and convert the string to HTML entities and wrap into the PRE tag to ensure it is displayed in the same way as it was on the console. I'm not sure if you can modify this behaviour without extending the JUnit ant task source code.

MirecXP
  • 443
  • 7
  • 18
  • This is, in my opinion, more considered a comment rather than an answer. Or at the most, an explanation of incorrect assumptions. – mattias Nov 09 '14 at 19:10
0

if you really need to do "this.." you can maybe use JEditorPane.. and some GUI.. but sure, your console will be NEVER able to do such things..

Andrea Bori
  • 190
  • 2
  • 15
0

Use URL. You can do

URL myURL = new URL("http://example.com/");

Then just

System.out.println(myURL);

This will output your URL and not "myURL"

Seth T
  • 68
  • 1
  • 7