Eclipse console doesn't show the whole output - java

In Java I tried to write a String as an output to the console. The length of the String is 20166 characters. After printing the string to the console only second half of the String appears.
The whole string is one long line:
What it looks like:
From the beginning there is a lot of whitespaces (which are supposed to be alphanumeric characters) and after that there is the rest of the string displayed properly.
I tried to change console encoding from default to UTF-16 and UTF-8, but it didn't help.
The String I am trying to output is text content crawled from a specific webpage (http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery). If I crawl a different webpage there is no problem.
How I process the string:
I use a webservice to get the text content from the webpage. The returned String (text contet) is printed properly (whole). I need to process this string so I change all characters to lowercase and replace all multiple whitespaces with the single one.
textContent.toLowerCase().replaceAll("\\s+", " ");
After lowercasing the characters I am still able to print whole string properly, but after replacing the multiple whitespaces with one, the beginning of string is not visible.
Do you have any idea what the problem is?
Thakns in advance for any help.

This is no bug. It is 1 of the changeable settings that Eclipse includes to make the output more readable.
It can be changed by going to Windows --> Preferences --> Run/Debug --> Console and then unchecking "Limit Console Output" which is ON by default.
For more information and details about these settings visit:
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Freference%2Fpreferences%2Frun-debug%2Fref-console.htm
This works on STS any version too. This would help printing complete console output.

What are the preferences for the console? Especially check the settings "Fixed width console" plus "Limit console output". Maybe your console simply can't hold that many characters in one line.
In Eclipse if you go to preference and in the drop-down, you can see RUN/DEBUG option if you click on that RUN/DEBUG drop-down you can see the console button and there you can adjust the "Fixed width console" plus "Limit console output"
[EDIT] Now Eclipse eventually has to cut the data in the console since it doesn't have infinite amounts of memory. If the console is still cut off, you can use this trick: Open the "Run Configurations" dialog (Found in the drop down menu for the green "run" button).
The tab "Common" tab has options in the "Standard Input and Output" group at the bottom to save a copy of all output in a file. You can then use your OSs tools to examine this file.
Also note that very long lines can make Eclipse slow (i.e. it can hang for a couple of seconds). This is due to a bug in the regexp matching patterns for Exception stack traces. If that happens, limit the line length to 1000 characters or less.
This is especially a problem with Spring which sometimes creates exceptions that have 50'000 characters in the message.
If you have a similar problem with the CDT Global Build Console, see here: Eclipse CDT Build Console output not displaying entire compiler output

Check whether the console buffer size is enough for your case, in Preference. Usually it's 80000 characters, just in case it's been changed.

Check this bug: Long Lines not printed to console, which is a duplicate of Bug 23406, opened in 2002 and not fixed yet! I just discovered it in Eclipse 2020-06, then I tried also the very old Ecipse Mars and it works. They says that the problem affects not only the console but also editors. A comment says "This bug has too many dups for a WONTFIX".

Related

No cyrillic symbols in a string in IntelliJ IDEA

i've started developing in IntelliJ in Java, created a new gradle project, added a few libraries but encountered a problem that a string is not being filled with cyrillic symbols - instead i get incorrect symbols (screenshot attached). How can i fix it? It has something to do with encodings - I tried a lot of suggestions on the web but nothing helped. Cheers!
Just change all encodings into UTF-8 (or other preferable encoding) and reload all java files into UTF-8.
You must know how to do first part (if you don't: File(top left corner of your window)>Settings>Editor>File Encodings).
The second part is also easy: just click on encoding in bottom right corner of the window and choose UTF-8 (or other preferable encoding).
Then you will have window like shown below. Choose "Reload" and enjoy. If you still have questions you are free to ask.
Here better description: https://www.jetbrains.com/help/idea/encoding.html

Copy and paste java code spacing gives errors

I copied and pasted code and Eclipse is giving me an error. I can fix it by deleting the spacing at the beginning of the lines but that is very tedious. It is the most recent version. Any ideas?
Try turning on display of control characters. Under Preferences > General > Editors > Text Editors. There is a checkbox labeled "Show whitespace characters". Then you could potentially do a global replace if that is the issue.
I have seen such errors in the past in other language (ActionScript) in eclipse. The problem there was that the used whitespace character was not the usual one to encode a blank but the one that encoded a blank that should not be broken apart into two lines. I would expect normaly this should not be an issue in Java because it uses unicode ... but probably your file has some other encoding (not unicode)!?
You should check:
Does the encoding of your file support unicode (in the eclipse "Properties" of the file). Probably changing the encoding solves your problem.
Look in some hex editor into the problematic file and check the character of the problematic blanks. Probably you have copy/paste your code from some webpage and there was such a character used to prevent the browser to break the code into multiple lines.
There are different unseen characters. What I do is to paste to a text editor (such as Notepad ++) and I say remove formatting. It removes these unseen characters and copy from it and paste it to the eclipse without any problem.

is there any limit to print the values on console in eclipse indigo or any other IDE?

I recently came across the problem of printing 4219 lines on console. but when excuted the program i saw that only half of the lines were printed. when i used debug mechanism i found that all the values are coming and getting printed on the console.
so is there a limit for the console to print the values if so how to make it to print all.
thanks
Antony
You can do it with console properties:
This is usually a setting for the console program. Open eclipse properties and search for console.
You need to increase the Console buffer size.
For Eclipse it is here: Preferences -> Run/Debug -> Console -> you should see entry for buffer size.
So i guess you have something similar. Just increase the number.
Go to Window/Preferences/
then choose
Run/Debug/Console
and take a look on "Console buffer size". I typically increase this number. Do the same.

JTable won't display Unicode correctly when the application is executed from the command line or a jar file. It works fine in eclipse, though

I'm writing an application that reads a text file containing a list of vocabulary words in both English and Chinese. These are then displayed in a JTable. When I run or debug the app in Eclipse, everything displays fine. I can see and read the characters and the English. However, when I execute the app from the command line or from an executable jar, it's all wrong. The characters show up as either squares or as gibberish.
I also have a text box that when I type Chinese into it, it displays correctly.
My first thought was that it was a font problem. I was using a font installed on my system. Since I can't guarantee that the person using this app will have that font, I moved it to a resource folder and load the font from a file. The font appears as though it's been loaded so I'm convinced it's not a font issue.
I found another question that suggested using -Dfile.encoding=utf-8. I've tried this and it did not work.
Would the brilliant folks at Stack Overflow have any advice on how to make this work?
I'm writing this on a non-chinese version of Windows.
Well then you won't ever be able to get a Java program to produce Chinese command-line output.
Java, like almost all languages, uses the C standard library which has byte-based IO. The Windows command prompt interprets byte-based IO using the locale-specific default code page. That's never a UTF, so Unicode characters outside of the current locale's default code page just won't work.
(In theory you should be able to get it to work by changing your console fonts and using chcp 65001 (UTF-8) together with -Dfile.encoding=UTF-8, but in practice it doesn't work reliably due to bugs in the C runtime. Unicode on the command prompt is a long-standing sore point.)

Blank line when inserting code template in Eclipse

I have been working with customizing the formatter in Eclipse to suit my style and I finally feel like it seems to do it exactly as I want it to except when inserting templates.
Whenever I use any Eclipse template (for example "Add unimplemented methods") it inserts a blank line before the code, even though the "Blank Lines" settings is set to 0 for "Before method declarations".
Anyone who knows how to disable this blank line or do I have to remove it manually every time?
I have the same issue with Eclipse too, and it's been a pet peeve of mine for some time. I believe it's a bug, because it has nothing to do with the formatting settings at all - turning off all 'new line' features and setting all 'blank line' parameters to 0 still doesn't fix the issue. You might want to report it as a bug.

Categories

Resources