Solved

JVM encoding. How to change encoding.

Posted on 2016-08-31
27
99 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
map related example 6 47
xampp tool 12 48
iterator/ListIterator approach 17 25
Which non-HTML GUI front end to use with Java? 3 21
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

786 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