Link to home
Start Free TrialLog in
Avatar of SunnyX
SunnyX

asked on

JVM encoding. How to change encoding.

To make story short, I simplify my case as much as possible.
Please take a look on this share pic
https://gyazo.com/cfea9042b2b2d9f7f8959de7c2913055

Please tell me what I'm doing wrong. I use encoding codes from this table
http://scratchpad.wikia.com/wiki/Character_Encoding_Recommendation_for_Languages
For example I need Albanian.

The restriction is that no source code changes allow.
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Please take a look on this share pic
Couple of things there

a. there's no need to link to external sites - it's quite possible to post images directly on this one
b. in most cases you want to copy from cmd.exe and paste here (see below)

Please post the output of the following

java Props file.encoding

Open in new window


See ( http://technojeeves.com/index.php/aliasjava1/16-javasystemproperties )

Oh and it might help to post the code of that HelloWorld too
Avatar of SunnyX
SunnyX

ASKER

If shortly, in command line :

I change chcp on 1250
makes: javac myClass.java
makes: java myClass

and still haven't good letters
in my output
Avatar of SunnyX

ASKER

C:\Users\***\*** Drive\*** development\*** all\***\dev\projects\***\*\src\main\java>chcp
Active code page: 437

C:\Users\*****\*** Drive\*** development\*** all\***\dev\***\***\*\src\main\java>chcp
 1250
Active code page: 1250

C:\Users\***\**** Drive\Software development\*** all\***\dev\projects\***\***\src\main\java>chcp
Active code page: 1250

C:\Users\***\Google Drive\Software development\myGJJ
all\GJJRepoAlgoLevelTwo\dev\projects\getjavajob\algo\src\main\java>java com.***.***.***.***.***
.HelloWorldAlbanian
P???rsh???ndetje bot???!

C:\Users\***\*** Drive\*** development\*** all\***\dev\projects\***\***\src\main\java>
That's not an answer to the question i asked. In fact it really repeats information you have already given
Avatar of SunnyX

ASKER

Error: Could not find or load main class Props

Open in new window

Avatar of SunnyX

ASKER

....\dev\projects\***\algo\src\main\java\com\***\***\***\***\***>java Props file.encoding
Error: Could not find or load main class Props

Open in new window

Did you download and compile the Java source at the link?
Actually, this is too painful - we can leave the question of what encoding you are using as a mystery for future solution

Open a new cmd.exe window and run your code like this:
java -Dfile.encoding=windows-1252 WhateverYourClassIs

Open in new window

Avatar of SunnyX

ASKER

The same garbage output...

P�rsh�ndetje bot�!
Avatar of SunnyX

ASKER

-Dfile.encoding ... seems make no difference at all

when I change chcp on 65001
the output is:
P�rsh�ndetje bot�!

However, when I do Dfile.encoding=windows-65001 the output is P�rsh�ndetje bot�! ( like the first one )
I even, by mistake, write down Dfile.encoding=windows-65002 and cmd throw the same garbage P�rsh�ndetje bot�!
However, by logic it should throw exception instead...
but  the cmd didn't tell me that there is any mistake ( like "Invalid code page"  like chcp doing )
btw, I use Windows 10
Avatar of SunnyX

ASKER

and yes I switch on lucida console
Actually i now DO need the output i asked for HERE so please compile and run Props.java in the way i showed
And you didn't post the source for HelloWorldAlbanian as i requested
So have you tried code pages

1252

and also ISO

8859-1
8859-2
8859-9
8859-15.
Avatar of SunnyX

ASKER

And you didn't post the source for HelloWorldAlbanian as i requested

Open in new window


Sorry,
Here the source code.
package com.g*********.***.al***.***.l***;

/**

 */
public class HelloWorldAlbanian {
    public static void main(String[] args) {
        System.out.println("P�rsh�ndetje bot�!");
    }
}

Open in new window


Actually i now DO need the output i asked for HERE so please compile and run Props.java in the way i showed

I'm so sorry. I really wanna give you output from the
java Props file.encoding

Open in new window

But once again it gives me nothing when I try to compile the code as I post before HERE    Are you sure that this is valid command ? in which folder should I run it ??? May be I made mistake by running the command in wrong folder. Because you know there is a difference between running java and javac require different folders for example ( because of the packages ) like it mention in https://javarevisited.blogspot.com/2015/04/error-could-not-find-or-load-main-class-helloworld-java.html
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SunnyX

ASKER

btw, I generate .class file by using this command in cmd

javac -encoding Windows-1252 MyClass.java

Open in new window


and beforehand I change chcp on 1252 too
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SunnyX

ASKER

Okey I'm done. Now everything fine. The solution was I need to reload file after I change encoding in ide.
https://gyazo.com/8b6da5f005c2a1ed7fd5c04046568956
after than I generate new .class file with chcp 1252 and everything good now ! thx for your time

https://gyazo.com/bbd0c35832f91a46537eed7ad77e51b9
Avatar of SunnyX

ASKER

Thx a lot !
OK. btw afaics there's absolutely nothing special about Albanian. The standard code pages /encodings should do it fine
1252 eh? Rings a bell.
Sunnyx are you friends with guddi9?
@gurpsbassi

Are you suggesting a Romano-Latin axis ?

I also think , CEHJ, that Albanian does have special alphabetic elements not present in other languages.
I also think , CEHJ, that Albanian does have special alphabetic elements not present in other languages.
Not sure what you have in mind but the OP's own link at http://scratchpad.wikia.com/wiki/Character_Encoding_Recommendation_for_Languages shows that windows-1252 (default in the UK) can cope with Albanian, so i don't see how they could be particularly exotic ;)
The webpage SunnyX uses then must be wrong, would you say? Albanian does not figure in the 1252 table that I came upon elsewhere.