Solved

JVM encoding. How to change encoding.

Posted on 2016-08-31
27
62 Views
Last Modified: 2016-09-02
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.
0
Comment
Question by:SunnyX
  • 12
  • 10
  • 4
  • +1
27 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 41778343
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
0
 

Author Comment

by:SunnyX
ID: 41778410
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
0
 

Author Comment

by:SunnyX
ID: 41778429
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>
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 41778458
That's not an answer to the question i asked. In fact it really repeats information you have already given
0
 

Author Comment

by:SunnyX
ID: 41778497
Error: Could not find or load main class Props

Open in new window

0
 

Author Comment

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

Open in new window

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 41778504
Did you download and compile the Java source at the link?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 41778523
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

0
 

Author Comment

by:SunnyX
ID: 41778673
The same garbage output...

P�rsh�ndetje bot�!
0
 

Author Comment

by:SunnyX
ID: 41778687
-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
0
 

Author Comment

by:SunnyX
ID: 41778690
and yes I switch on lucida console
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 41778908
Actually i now DO need the output i asked for HERE so please compile and run Props.java in the way i showed
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 41778911
And you didn't post the source for HelloWorldAlbanian as i requested
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 16

Expert Comment

by:krakatoa
ID: 41779471
So have you tried code pages

1252

and also ISO

8859-1
8859-2
8859-9
8859-15.
0
 

Author Comment

by:SunnyX
ID: 41779548
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
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 41779557
Here the source code.
OK, but that's not helpful - as you can see - this site has not reproduced it properly.
Please do two things:

a. attach it as a file
b. post a screenshot of the source
0
 

Author Comment

by:SunnyX
ID: 41779593
0
 

Author Comment

by:SunnyX
ID: 41779596
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
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 500 total points
ID: 41779598
But ... that is already messed up. All it shows are question marks. How is that Albanian?
0
 

Author Comment

by:SunnyX
ID: 41779633
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
0
 

Author Closing Comment

by:SunnyX
ID: 41779635
Thx a lot !
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 41779648
OK. btw afaics there's absolutely nothing special about Albanian. The standard code pages /encodings should do it fine
0
 
LVL 16

Expert Comment

by:krakatoa
ID: 41779751
1252 eh? Rings a bell.
0
 
LVL 15

Expert Comment

by:gurpsbassi
ID: 41780735
Sunnyx are you friends with guddi9?
0
 
LVL 16

Expert Comment

by:krakatoa
ID: 41780781
@gurpsbassi

Are you suggesting a Romano-Latin axis ?

I also think , CEHJ, that Albanian does have special alphabetic elements not present in other languages.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 41781173
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 ;)
0
 
LVL 16

Expert Comment

by:krakatoa
ID: 41781980
The webpage SunnyX uses then must be wrong, would you say? Albanian does not figure in the 1252 table that I came upon elsewhere.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now