Click here to Skip to main content
15,920,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I'd like to test this code(for example) on PC connected to Internet using NetBeans 6.9
Java
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
}


Is this possible and how?
thanks.

EDIT:
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.
Posted
Updated 30-Jul-10 10:12am
v4
Comments
Sandeep Mewara 30-Jul-10 15:57pm    
Use PRE tags to format code part. It makes the question readable.

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?
 
Share this answer
 
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.
 
Share this answer
 
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900