[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
JAVA question. i made a console app in java. works flawlessly
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 27
Thread images: 2
File: javalogo.png (39 KB, 518x518) Image search: [Google]
javalogo.png
39 KB, 518x518
JAVA question.

i made a console app in java. works flawlessly on my pc, but does not display text properly on console of another computer. what could be the reason? console settings are the same, console coding is the same, i can't get it working on 2nd computer as it displays squares and stuff.

both computers are windows 10 pro machines. any java guru knows whats going on?
>>
> Java
/thread

No clue desu senpai
>>
>>54816523
>displays squares and stuff
encoding? specify UTF-8 somewhere idk
>>
>>54816557
i was changing console's coding and tried every possible one and still not displaying correctly.. is it possible to globally set encoding of application in code?
>>
>>54816583
does any of your output even use non unicode characters?

look at this
https://docs.oracle.com/javase/tutorial/i18n/text/string.html
>>
String original = "Something";
byte[] bytes = original.getBytes(StandardCharsets.UTF-8);
String final = new String(bytes, StandardCharsers.UTF-8);
System.out.println(final);
>>
>>54816639

it does use "trick" to clear a console, specifically this:

System.out.print("\033[H\033[2J");

>>54816652
will check this in a moment
>>
>>54816652
this does not work
>>
>>54816765
String original = "Something";
byte[] bytes = original.getBytes(StandardCharsets.US_ASCII);
String final = new String(bytes, StandardCharsers.US_ASCII);
System.out.println(final);
>>
>>54816966
this does not work at all. the main problem in my program is that console clearing doesnt work. somehow it works on windows 10 pc, but doesnt on windows 10 laptop by escape code. wtf im tired of this shit nothing works..
>>
>>54817222
Its not character encoding then. Its some other crap.
>>
>>54817239
do you know how to clear fucking console in this fucking java?
>>
Java: Write Once, Debug Everywhere.
>>
>>54817308
Saying that Java is nice because it works on every OS is like saying that anal sex is nice because it works on every gender
>>
>>54817308
yeah... this crap doesnt support anything properly.. making console apps in c# is WAY better, easier and more functional.
>>
>>54817275
>>54817388
You echo a specific string that Bash recognizes and clears the screen.

Or on Windows do the following:

Process p = Runtime.getruntime().exec("cls");
>>
Check your console locale (language setting).
Windows CMD are shit because you can't set language character set like any other OS.

on *nix, you can use export LANG=en-us.utf8 or something.
>>
>>54817412
tried both. none works on laptop. the escape code to clear console works on my pc though. it has same OS version as laptop, same console settings and it doesnt work on laptop. im downloading windows update right now on shittop.. maybe it'll help.

>>54817425
you can change console encoding on windows by entering:
mode con cp select=x
where x is determining encoding..

none works on laptop ffs.
>>
If you didn't do anything retarded in your program then it's probably just the other computer being stupidshit. Did you just use system.out.print()? Does the stupidshit computer display other programs normally? Are you just trying it with the java text files or exporting some huge eclipse project?
>>
>>54816523
Install gentoo
>>
File: readImage.jpg (16 KB, 320x320) Image search: [Google]
readImage.jpg
16 KB, 320x320
>>54817388
>>54817459

Then its obviously something wrong with the laptop. You can't blame Java for Microsofts shitty Virtual Terminal.
>>
>>54817459
Then, maybe you lack the font for that charset ?
>>
>>54817488
>>54817471
yeah its probably the case. im downloading update v1511 for windows right now on laptop. i read on reddit that it adds escape codes to windows's cmd. i am trying to clear screen by printing the escape code with "system.out.print" as i say works flawlessly on pc, doesnt on laptop. i hope it will help but the update download is fucking stuck..
>>
>>54817459
It's not a Java only problem.

See:
http://stackoverflow.com/questions/23727211/how-to-display-text-in-the-locale-of-the-command-line

tl;dr: Windows use codepage, while your code might use ascii or unicode.
>>
>>54816523
My first train of thought debugging this would be to make sure you have the latest version of Java on both devices. Two, instead of printing to the console directly, see what happens if you were to print to a text file instead either using something like PrintWriter or FileOutputStream. See how the text file differs on both computers. If they don't differ at all then something sketchy is up.
>>
OP here. windows update solved issue.
>>
>>54820428
Strange but as long as it works.
Thread replies: 27
Thread images: 2

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.