blainehilton
asked on
Requesting a URL
I have an application where I need a java program that will open up a URL and cause the web page to be ran. The java program will be opening a web page that is itself a PHP script.
The code that I have been playing around with is like this:
-------------------------- ---------- ---------- ---------- ---------- ------
import java.net.*;
import java.io.*;
class Link {
public static void main(String[] args) {
try
{
URL url = new URL("http://192.168.5.100/index.php");
URLConnection connection = url.openConnection();
}
catch (Exception e)
{
System.out.println(e.toStr ing());
}
}
}
-------------------------- ---------- ---------- ---------- ---------- -----
Any help would be appreciated.
Also I am using an older version of Java if that matters, I believe it is version 1.2.2. Please explain your solutions in detail as I have very little Java knowledge.
--
Thanks in Advance
Blaine
The code that I have been playing around with is like this:
--------------------------
import java.net.*;
import java.io.*;
class Link {
public static void main(String[] args) {
try
{
URL url = new URL("http://192.168.5.100/index.php");
URLConnection connection = url.openConnection();
}
catch (Exception e)
{
System.out.println(e.toStr
}
}
}
--------------------------
Any help would be appreciated.
Also I am using an older version of Java if that matters, I believe it is version 1.2.2. Please explain your solutions in detail as I have very little Java knowledge.
--
Thanks in Advance
Blaine
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you for your fast response, no I do not need to view the page, just have it run the PHP.
I ran the code you sent and it complied fine but when I ran it I received an error saying "java.net.MalformedURLExce ption". This is the same error I was having with my example.
I ran the code you sent and it complied fine but when I ran it I received an error saying "java.net.MalformedURLExce
strange it looks alright, is the URL you are using the same as what is posted here?
ASKER
The URL is pretty much the same, but is different. It is an IP address and not a hostname and I am using the http:// and the page does exist, and the device can ping the server.
Does it matter that this is running on a TINI Module? (http://www.ibutton.com/TINI/index.html)
When I run it with the command "java Link.class" from the DOS prompt I receive a different error. The dos prompt gives me:
Exception in thread "main" java.lang.NoClassDefFoundE rror: Link/class
Does it matter that this is running on a TINI Module? (http://www.ibutton.com/TINI/index.html)
When I run it with the command "java Link.class" from the DOS prompt I receive a different error. The dos prompt gives me:
Exception in thread "main" java.lang.NoClassDefFoundE
> When I run it with the command "java Link.class"
should be:
java Link
should be:
java Link
> The URL is pretty much the same, but is different.
what is it exactly then?
what is it exactly then?
ASKER
Using the command "java Link" it worked great, however it is not working on the TINI.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Let me know if you need more details.