如何在PC而非手机上测试某些Internet功能? [英] How to test some internet-funcs on PC, not on Mobile phone?

查看:87
本文介绍了如何在PC而非手机上测试某些Internet功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想在使用NetBeans 6.9连接到Internet的PC上测试此代码(例如)

Hi,
I''d like to test this code(for example) on PC connected to Internet using NetBeans 6.9

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import javax.microedition.io.*;
import java.io.*;
/////////////

try{
HttpConnection connection = (HttpConnection) Connector.open("http://somenonexistentsite");
        connection.setRequestMethod(HttpConnection.GET);
        connection.setRequestProperty("Content-Type","//text plain");
        connection.setRequestProperty("Connection", "close");
textBox.setString("ok"); // <=== when started On PC
}
catch(IOException e)
{
textBox.setString("unable to open url");//<<== ...on Mobile Phone
}



这可能吗?
谢谢.


我已将PC连接到Internet,并安装了JDK和netbeans-6.9-ml-windows.exe.开始发布代码后,无论我写了什么URL,我总是在TextBox中看到"OK".



Is this possible and how?
thanks.


I have PC connected to Internet, and installed JDK and netbeans-6.9-ml-windows.exe. Starting posted code, I always see "OK" in TextBox, whatever url I wrote.

推荐答案

您是否有一台装有Java开发环境的PC?如果是这样,那是什么问题,如果不是就从那里开始.

PC下一步可以访问互联网吗?
Do you have a PC with java development environment setup? If so, what is the issue, if not start right there.

Next does the PC has internet access?


很可能当HttpConnection()尝试连接到不存在的URL时,它会得到404(或类似的)响应,而不是抛出例外.尝试读取连接的响应并显示其文本,而不是通用的"OK".您可能还希望通过调试器逐步检查代码,以查看发生了什么.
It is likely that when the HttpConnection() tries to connect to a non-existent URL it gets a 404 (or similar) response rather than throwing an exception. Try reading the response from the connection and displaying its text rather than the generic "OK". You may also like to step through your code with the debugger to see what is happening.


http://www.oracle.com/technetwork/java/javame/downloads/index.html[^]

The SDK/IDE for the Java ME platform has an emulator, if that''s what you mean.


这篇关于如何在PC而非手机上测试某些Internet功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆