在我看来,MIDP中的套接字创建存在某种限制.我需要与服务器建立很多连接(没有任何结果),并在第四或第四次尝试我的应用程序崩溃.它在模拟器和我的真实设备中也崩溃了.
为了隔离它受我的代码影响的任何可能性,我隔离了以下代码:
try {
StreamConnection c;
StringBuffer sb = new StringBuffer();
c = (StreamConnection) Connector.open(
"http://www.cnn.com.br/", Connector.READ_WRITE);
InputStreamReader r = new InputStreamReader(c.openInputStream(), "UTF-8");
System.out.println(r.read());
c.close();
} catch (IOException ex) {
ex.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
这段代码在第13次尝试中崩溃了.
我试着在一个while循环中添加一个10秒的睡眠,并且它在第13次尝试也崩溃了.
崩溃消息是:
java.io.IOException: Resource limit exceeded for TCP client sockets
- com.sun.midp.io.j2me.socket.Protocol.open0(), bci=0
- com.sun.midp.io.j2me.socket.Protocol.connect(), bci=124
- com.sun.midp.io.j2me.socket.Protocol.open(), bci=125
Run Code Online (Sandbox Code Playgroud) 我知道如何使用drawTexturePath在任何角度旋转图像:
int displayWidth = Display.getWidth();
int displayHeight = Display.getHeight();
int[] x = new int[] { 0, displayWidth, displayWidth, 0 };
int[] x = new int[] { 0, 0, displayHeight, displayHeight };
int angle = Fixed32.toFP( 45 );
int dux = Fixed32.cosd(angle );
int dvx = -Fixed32.sind( angle );
int duy = Fixed32.sind( angle );
int dvy = Fixed32.cosd( angle );
graphics.drawTexturedPath( x, y, null, null, 0, 0, dvx, dux, dvy, duy, image);
Run Code Online (Sandbox Code Playgroud)
但我需要的是一个带有3d变换的简单图像的三维投影(类似这样)
你能告诉我如何使用drawTexturedPath(我几乎可以肯定这是可能的)吗? …
我正在尝试使用java me sdk 3.0 来使用hessian j2me实现@ http://hessian.caucho.com/.
http://hessian.caucho.com/doc/hessian-overview.xtp#Hessian%20Client%20for%20a%20cell-phone提到了j2me的用法.
应用程序构建时没有任何错误/警告.但是,在MicroHessianOutput实例化实例化的行的那一刻,java.lang.Error: ClassFormatError: 56
抛出了ClassFormatError().
继承人追踪:
TRACE: <at java.lang.Error: ClassFormatError: 56>, startApp threw an Exception
java.lang.Error: ClassFormatError: 56
- alert.AlertDemo.showOption(), bci=26
- alert.AlertDemo.startApp(), bci=9
- javax.microedition.midlet.MIDletTunnelImpl.callStartApp(), bci=1
- com.sun.midp.midlet.MIDletPeer.startApp(), bci=7
- com.sun.midp.midlet.MIDletStateHandler.startSuite(), bci=269
- com.sun.midp.main.AbstractMIDletSuiteLoader.startSuite(), bci=52
- com.sun.midp.main.CldcMIDletSuiteLoader.startSuite(), bci=8
- com.sun.midp.main.AbstractMIDletSuiteLoader.runMIDletSuite(), bci=161
- com.sun.midp.main.AppIsolateMIDletSuiteLoader.main(), bci=26
Run Code Online (Sandbox Code Playgroud)
和继承人showOption():
private void showOption () throws Exception{
String url = "http://localhost/hello";
HttpConnection c = (HttpConnection) Connector.open(url);
c.setRequestMethod(HttpConnection.POST);
OutputStream os = c.openOutputStream();
MicroHessianOutput out …Run Code Online (Sandbox Code Playgroud) 如何在BlackBerry上将InputStream转换为String?
我正在使用Bouncy Castle来加密字符串以将它们发送到我的java Web服务,在那里它们被解密,当消息到达我得到的服务器时BadPaddingException,任何人都知道如何在J2ME上正确地将填充添加到带有Bouncy Castle的RSA Cipher?
这是客户端上的加密代码:
public byte[] Encrypt(byte[] data)
{
RSAKeyParameters publicKey = new RSAKeyParameters(false, new BigInteger(_publicKeyModulus), new BigInteger(_publicKeyExponent));
RSAEngine engine = new RSAEngine();
engine.init(true, publicKey);
byte[] output = engine.processBlock(data, 0, data.length);
return output;
}
Run Code Online (Sandbox Code Playgroud)
这就是我解密服务器端的方式:
public byte[] Decrypt(byte[] data)
{
try {
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.DECRYPT_MODE, privateKey);
byte[] cipherData = cipher.doFinal(data);
return cipherData;
} catch (NoSuchAlgorithmException ex) {
Logger.getLogger(EncryptorDecryptor.class.getName()).log(Level.SEVERE, null, ex);
} catch (NoSuchPaddingException ex) {
Logger.getLogger(EncryptorDecryptor.class.getName()).log(Level.SEVERE, null, ex);
} catch(IllegalBlockSizeException ex) {
Logger.getLogger(EncryptorDecryptor.class.getName()).log(Level.SEVERE, null, …Run Code Online (Sandbox Code Playgroud) 我使用Sun java无线工具包2.5.2和LWUIT用于我的j2me应用程序.我添加了一个CommandExit.按下时Exit Command,我只是调用destroyApp(true);它已成功退出,然后模拟器显示启动屏幕.现在,如果我再次按下启动,我的应用程序不会打开.所以,我的代码有什么问题吗?
请指导我摆脱这个问题.

我想为我的黑莓项目创建一个具有精确外观的工具栏.任何帮助是极大的赞赏.请注意我不能使用ToolBarManager.我的项目应该支持OS 5.0之后的所有设备
谢谢
我正在尝试使用分割文本在j2me中创建一个数组.我正在尝试使用ostermiller.org中的StringTokenizer类.但是我无法弄清楚如何将标记分配到数组中.这段代码有什么问题?
String[] myToken;
StringTokenizer tokenObject;
tokenObject = new StringTokenizer("one-two-three","-");
myToken= tokenObject.nextToken();
Run Code Online (Sandbox Code Playgroud) 我正在J2ME中开发一些发送和接收加密消息的应用程序,我发现下面的代码加密它并转换为String但它不起作用并抛出异常,我应该怎么做?当我想要解密时,我应该如何将String转换为byte []?谢谢
byte[] plainArray = message.getBytes();
try {
byte[] keyBytes = "SECRET_1SECRET_2SECRET_3".getBytes();
// key = new KeyParameter(keyBytes);
AESEngine engine = new AESEngine();
PaddedBufferedBlockCipher cipher = new PaddedBufferedBlockCipher(engine);
cipher.init(true, new KeyParameter(keyBytes));
byte[] cipherBytes = new byte[cipher.getOutputSize(plainArray.length)];
int cipherLength = cipher.processBytes(plainArray, 0, plainArray.length, cipherBytes, 0);
cipher.doFinal(cipherBytes, cipherLength);
String result2 = org.apache.commons.codec.binary.Base64.encodeBase64String(cipherBytes);
formSender.append(result2);
} catch (Exception e) {
}
Run Code Online (Sandbox Code Playgroud)
例外:
TRACE:,Exception陷入Display类java.lang.Error:ClassFormatError:56 SSMS.EncShow(),bci = 173 at SSMS.commandAction(),bci = 16 at javax.microedition.lcdui.Display $ ChameleonTunnel.callScreenListener( ),bci = 44 at com.sun.midp.chameleon.layers.SoftButtonLayer.processCommand(),bci = 80 at com.sun.midp.chameleon.layers.SoftButtonLayer.soft1(),bci = 31 …
我写了以下java代码:
public static void main(String[] args) {
Vector vector = new Vector();
for(int i=1; i<=10; i++)
vector.addElement(i);
Enumeration vEnum = vector.elements();
while(vEnum.hasMoreElements())
System.out.println(vEnum.nextElement());
}
Run Code Online (Sandbox Code Playgroud)
在编译它时会收到以下警告消息:
Note: TestJavaApplication.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Run Code Online (Sandbox Code Playgroud)
Netbeans抱怨"过时收藏"的消息.
在这种情况下,你推荐我什么?
注意,我需要在J2ME应用程序中使用Vector作为存储元素顺序的动态数组.我很乐意使用Hashtable但不幸的是它不存储其元素的顺序.
编辑1
审查后,这个答案我从改变报关Vector vector = new Vector();进入Vector<String> vector = new Vector<String>();.现在又收到另一条警告信息:
TestJavaApplication.java:2: warning: com.sun.org.apache.xerces.internal.parsers.IntegratedParserConfiguration is Sun proprietary API and may be removed in a future release
import com.sun.org.apache.xerces.internal.parsers.IntegratedParserConfiguration;
^
Run Code Online (Sandbox Code Playgroud)
谢谢.
java-me ×10
java ×5
blackberry ×4
bouncycastle ×2
lwuit ×2
midp ×2
3d ×1
base64 ×1
eclipse ×1
emulation ×1
encryption ×1
graphics ×1
hessian ×1
lwuit-form ×1
rpc ×1
rsa ×1
sockets ×1
vector ×1