JAVA question

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?

Other urls found in this thread:

docs.oracle.com/javase/tutorial/i18n/text/string.html
stackoverflow.com/questions/23727211/how-to-display-text-in-the-locale-of-the-command-line
twitter.com/SFWRedditGifs

> Java
/thread

No clue desu senpai

>displays squares and stuff
encoding? specify UTF-8 somewhere idk

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?

does any of your output even use non unicode characters?

look at this
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);

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

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

will check this in a moment

this does not work

String original = "Something";
byte[] bytes = original.getBytes(StandardCharsets.US_ASCII);
String final = new String(bytes, StandardCharsers.US_ASCII);
System.out.println(final);

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..

Its not character encoding then. Its some other crap.

do you know how to clear fucking console in this fucking java?

Java: Write Once, Debug Everywhere.

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

yeah... this crap doesnt support anything properly.. making console apps in c# is WAY better, easier and more functional.

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.

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.

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?

Install gentoo

Then its obviously something wrong with the laptop. You can't blame Java for Microsofts shitty Virtual Terminal.

Then, maybe you lack the font for that charset ?

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..

It's not a Java only problem.

See:
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.

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.

Strange but as long as it works.