简体   繁体   中英

problem in java program when runs in windows JRE

Hi
I wrote a program in java.
in a part of program it extracts a string number from a web page and converts it to Integer. This works in linux without problem. In windows it works correctly when I run program from Netbeans's Run/Debug option;
But when i run it from windows and JRE it doesn't work! (It extracts that number incorrectly).
This is that part of code:

subcatPagesCount=0;
subcatPagesCount=Integer.parseInt(cutstring(CM.getResult(),"( صفحه 1 از "," )").trim());
lblPagesCount.setText(""+subcatPagesCount);

and "cutstring" method is:

private String cutstring(String in,String from,String to){
    int st=in.indexOf(from)+from.length();
    return in.substring(st,in.indexOf(to,st));
}

it Throws:

java.lang.NumberFormatException: For input string: "tml PUBLIC "-//W3C//DTD XHTM
L 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Typ
e" content="text/html;charset=UTF-8" /><title>کامپیوتر :: کامپیوت
ر و  قطعات - istgah.com </title><meta name="keywords" content=",istgah,ا
یستگاه,نیازمندیها , آگهی , تبلیغات , ایران" /><m
eta name="description" content="┌⌐╪º┘à┘╛█î┘ê╪¬╪▒ :: ┌⌐╪º┘à┘╛█î┘ê╪¬╪▒ ┘ê  ┘é╪╖╪╣╪
º╪¬ - istgah.com" /><base href="http://www.istgah.com/" /><link rel="stylesheet"
 type="text/css" href="layout/templates/istblue/css/firev4.css" /><link rel="sty
lesheet" type="text/css" href="layout/templates/istblue/css/style2.css" /></head
><body>  <div style="width:980px; float:right; " dir="rtl" >    <div style="widt
h:213px; height:89px; float:right; " dir="rtl" >          <a href="http://www.is
tgah.com/" >        <img border="0" alt="istgah.com" width="213" height="39" ali
gn="top" src="layout/blue/hr_top_right.gif" />      <img border="0" alt="istgah.
com" width="187" height="50" align="top" src="layout/blue/hr_top_right2.gif" />
  </a>    <div style="display:none;">       <img border="0" alt="" width="0" hei
ght="0" align="top" src="layout/blue/hr_top_right_back.gif" />    </div>
</div>    <div align="right" style="width:767px; height:39px; float:left; backgr
ound-image:url(layout/blue/hr_top_right_back.gif); " dir="rtl" >
<div style="width:360px; float:right; padding-top:17px; " >               <a hre
f="http://www.istgah.com">╪╡┘?╪¡┘ç ╪º╪╡┘ä┘è</a> |                 <a href="http:
//www.istgah.com/province/">استانها</a> |                  <a href="http:
//www.istgah.com/advertise/">نسخه قديم</a> |              <a href="http:
//www.istgah.com/user/">ثبت‌نام</a> |             <a href="http://www.is
tgah.com/contactus/">تماس باما</a>              </div>          <div ali
gn="left" style="width:90px; float:right; padding-top:17px; " >           <font
color="blue" >  </font>         </div>          <div align="left" style="width:3
00px; float:right; padding-top:17px; " >                        ╪º┘à╪▒┘ê╪▓: ΓǬ┌
å┘ç╪º╪▒╪┤┘å╪¿┘ç╪î █▓█╡ ╪º╪│┘?┘å╪» █▒█│█╕█╣ΓǼ           </div>  </div>    <div a
lign="right" style="width:767px; height:50px; float:left; " dir="rtl" >
<div style="width:260px; float:right; padding-top:20px; " >               <form
action="http://www.istgah.com/search/ " method="get">                   جستج
و:                     <input name="stext" class="inputbox" size="25" />
                <input type="image" src="layout/go.gif" align="top" />
  </form>               </div>          <div style="width:500px; float:right; "
>                 <table border="0" width="500px" cellspacing="0" class="mc" dir
="rtl" >  <tr>    <td>    <a href="http://www.istgah.com/fireview/computer/">

.....

http://www.istgah.com/firekeys/key_3551/" > samsung</a> - <a href="http://www.is
tgah.com/firekeys/key_136241/" > هارد اکسترنال</a> - <a href="http:/
/www.istgah.com/firekeys/key_3066/" > ┘?╪▒┘ê╪┤ ┌⌐╪º┘à┘╛█î┘ê╪¬╪▒</a> - <a href="h
ttp://www.istgah.com/firekeys/key_1535/" > acer</a> - <a href="http://www.istgah
.com/firekeys/key_13206/" > رایتر</a> - <a href="http://www.istgah.com/fire
keys/key_3100/" > ساعت</a> - <a href="http://www.istgah.com/firekeys/key_625
08/" > مودم adsl</a> - <a href="http://www.istgah.com/firekeys/key_3123/" >
ضبط</a> - <a href="http://www.istgah.com/firekeys/key_203/" > موبایل</a
> - <a href="http://www.istgah.com/firekeys/key_1276/" > laptop</a> - <a href="h
ttp://www.istgah.com/firekeys/key_7199/" > msi</a> - <a href="http://www.istgah.
com/firekeys/key_2270/" > monitor</a> - <a href="http://www.istgah.com/firekeys/
key_321385/" > 5200</a> - <a href="http://www.istgah.com/firekeys/key_807/" > cd
</a> - <a href="http://www.istgah.com/firekeys/key_1870/" > ups</a> - <a href="h
ttp://www.istgah.com/firekeys/key_927/" > تلویزیون</a> - <a href="http:/
/www.istgah.com/firekeys/key_2079/" > مادربرد</a> - <a href="http://www.i
stgah.com/firekeys/key_1723/" > sony</a> - <a href="http://www.istgah.com/fireke
ys/key_532/" > بازی</a> - <a href="http://www.istgah.com/firekeys/key_846/"
> cool disk</a> - <a href="http://www.istgah.com/firekeys/key_51650/" > ╪º┘ä ╪│█
î ╪»█î</a> - <a href="http://www.istgah.com/firekeys/key_51/" > ╪»┘ê╪▒╪¿█î┘å ╪»█
î╪¼█î╪¬╪º┘ä</a> - <a href="http://www.istgah.com/firekeys/key_13/" > ┌⌐╪º┘à┘╛█î┘
ê╪¬╪▒</a> - <a href="http://www.istgah.com/firekeys/key_1766/" > ╪¿╪º╪¬╪▒█î</a>
- <a href="http://www.istgah.com/firekeys/key_3454/" > dell</a> - <a href="http:
//www.istgah.com/firekeys/key_12084/" > mp4</a> - <a href="http://www.istgah.com
/firekeys/key_3637/" > ram</a> - <a href="http://www.istgah.com/firekeys/key_381
0/" > کارت کپچر</a> -           <br />      </td></tr>            <tr><t
d align="center" >         <br />          <form action="http://www.istgah.com/s
earch/ " method="get">          <b>جستجوگر هوشمند آگهی‌های
 ایستگاه: </b>           <input name="stext" class="inputbox" size="30" /
>               <input type="image" src="layout/go.gif" align="top" />     </for
m>         <br />         </td></tr>    </table>          <div>         <table w
idth="100%" cellpadding="0" cellspacing="0" class="nls" >               <tr><td
class="ghd" colspan="3" >تازه‌های کامپیوتر :: کامپیوتر
┘ê  ┘é╪╖╪╣╪º╪¬ ( ╪╡┘?╪¡┘ç 1 ╪º╪▓ 84"
        at java.lang.NumberFormatException.forInputString(Unknown Source)
        at java.lang.Integer.parseInt(Unknown Source)
        at java.lang.Integer.parseInt(Unknown Source)
        at istgahrobot.doscan$Scan.run(doscan.java:536)
        at java.lang.Thread.run(Unknown Source)

What's the problem?
Thanks

You're probably not running the JRE with Unicode switched on. Try running your code with the file.encoding option:

-Dfile.encoding=UTF8

Or set the JAVA_TOOL_OPTIONS environment variable to -Dfile.encoding=UTF8 .

See Setting the default Java character encoding? for more.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM