473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Reading Directly from a URL

I am following the The JavaT Tutorials Custom Networking Working with
URLs trail. The following code compiles with no complaints:

import java.net.*;
import java.io.*;

public class URLReader {
public static void main(String[] args) throws Exception {
URL yahoo = new URL("http://www.yahoo.com/");
BufferedReader in = new BufferedReader(
new InputStreamReader(
yahoo.openStream()));

String inputLine;

while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);

in.close();
}
}
When I run it, I get Exception in thread "main"
java.lang.NoClassDefFoundError: URLReader. I am working on my home computer
without a proxy, as far as I know. I tried disabling my firewall
temporarily but it did not help.Any suggestions?Thanks,Tharpa
Aug 18 '06 #1
4 4568
Tharpa Roberts wrote:
I am following the The JavaT Tutorials Custom Networking Working with
URLs trail. The following code compiles with no complaints:

import java.net.*;
import java.io.*;

public class URLReader {
public static void main(String[] args) throws Exception {
URL yahoo = new URL("http://www.yahoo.com/");
BufferedReader in = new BufferedReader(
new InputStreamReader(
yahoo.openStream()));

String inputLine;

while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);

in.close();
}
}
When I run it, I get Exception in thread "main"
java.lang.NoClassDefFoundError: URLReader. I am working on my home computer
without a proxy, as far as I know. I tried disabling my firewall
temporarily but it did not help.Any suggestions?Thanks,Tharpa

The code runs fine on my Windoze XP SP 2 machine with jdk1.5.0_07 under
Eclipse 3.2

Depends, how are you tying to run your URLReader.class file? You just
need to CD to that directory where your URLReader.class is and issue:

Java URLReader

--
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Aug 19 '06 #2
Tharpa Roberts wrote:
I am following the The JavaT Tutorials Custom Networking Working with
URLs trail. The following code compiles with no complaints:

import java.net.*;
import java.io.*;

public class URLReader {
public static void main(String[] args) throws Exception {
URL yahoo = new URL("http://www.yahoo.com/");
BufferedReader in = new BufferedReader(
new InputStreamReader(
yahoo.openStream()));

String inputLine;

while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);

in.close();
}
}
When I run it, I get Exception in thread "main"
java.lang.NoClassDefFoundError: URLReader. I am working on my home computer
without a proxy, as far as I know. I tried disabling my firewall
temporarily but it did not help.Any suggestions?Thanks,Tharpa

java -cp . URLReader
not:
java URLReader

You should set this up in your classpath environment variable... Then
you don't have to specify the cp all the time...
Aug 19 '06 #3
IchBin,

For some reason, it works this time. I'm sure what went wrong yesterday.

Thanks anyway.

Tharpa

IchBin wrote:
Tharpa Roberts wrote:
The code runs fine on my Windoze XP SP 2 machine with jdk1.5.0_07
under Eclipse 3.2

Depends, how are you tying to run your URLReader.class file? You just
need to CD to that directory where your URLReader.class is and issue:

Java URLReader
--
May all beings, in or out of the womb, be well, happy and peaceful.
http://mysite.verizon.net/tharpa/
Aug 20 '06 #4
Dear Sigmund,

For some reason, it works this time. I'm not sure what went wrong
yesterday.

Thanks anyway.

Tharpa
Sigmund Hansen wrote:
Tharpa Roberts wrote:

java -cp . URLReader
not:
java URLReader

You should set this up in your classpath environment variable... Then
you don't have to specify the cp all the time...
--
May all beings, in or out of the womb, be well, happy and peaceful.
http://mysite.verizon.net/tharpa/
Aug 20 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Dariusz | last post by:
I have PHP code (below) which reads data from a MySQL format database. The problem I am having is trying to find out when the last ID entry was made. When the script is executed, the $gbID is...
3
by: Simon | last post by:
Using qbasic, the following accepts input from com1, and prints its output : OPEN "com1:9600,n,8,1,CD0,CS0,DS0,RS" FOR INPUT AS #1 WHILE INKEY$ <> " " INPUT #1, a$ PRINT a$ WEND What...
4
by: nightflyer | last post by:
Hi all, [code snippet appended at the end.) my question: A class has a few string variables with not know length at design time. Now I declare lets say a 1000 of those classes and put them...
18
by: shakeel-ur-rehman | last post by:
I am wrtiting programm in C++ to read/take complete image of the partiton. can any one let me know the internet resources and web sites having tutorials relating to this and tell any sequence ...
5
by: Benjamin de Waal | last post by:
Hey all, I'm trying to figure out how to directly write to a device in Windows. Basically, what I'm wanting to do is create an image of a device (specifically, a CompactFlash card that uses a...
16
by: Ali | last post by:
Hi I want to write (or read) to a stream, but the data is not byte array I converted the data to byte array manually, but it is very slow, (becuse the data is very large) Is another way for this...
6
by: ALI-R | last post by:
Hi All; I'm reading the following xml file into a Dataset but there are only 4 datatables in my dataset (which should be 5) Is that because I have two nodes with the same name (detail) in my xml...
7
by: John Dann | last post by:
I'm trying to read some binary data from a file created by another program. I know the binary file format but can't change or control the format. The binary data is organised such that it should...
9
by: dba123 | last post by:
I need some help and direction on what classes and an example or two (article) on how to read an Excel Worksheet and insert one column into a database table column. I am using .NET 2.0 only. What...
13
by: anant | last post by:
Hi all The below code is reading string and then tokenizin it and reading all the info. But i want to call a csv file and it should then read a string from dt file. So what midification should i...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.