Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2006

Tip: Looking for answers? Try searching our database.

Reading Directly from a URL

Thread view: 
Tharpa Roberts - 18 Aug 2006 20:37 GMT
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
IchBin - 19 Aug 2006 01:21 GMT
> I am following the The JavaT Tutorials > Custom Networking > Working with
> URLs trail.  The following code compiles with no complaints:
[quoted text clipped - 21 lines]
> 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-)
Tharpa Roberts - 20 Aug 2006 02:50 GMT
IchBin,

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

Thanks anyway.

Tharpa

> The code runs fine on my Windoze XP SP 2 machine with jdk1.5.0_07
> under Eclipse 3.2
[quoted text clipped - 3 lines]
>
> Java URLReader

Signature

May all beings, in or out of the womb, be well, happy and peaceful.
http://mysite.verizon.net/tharpa/

Sigmund Hansen - 19 Aug 2006 02:30 GMT
> I am following the The JavaT Tutorials > Custom Networking > Working with
> URLs trail.  The following code compiles with no complaints:
[quoted text clipped - 21 lines]
> 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...
Tharpa Roberts - 20 Aug 2006 02:51 GMT
Dear Sigmund,

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

Thanks anyway.

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...

Signature

May all beings, in or out of the womb, be well, happy and peaceful.
http://mysite.verizon.net/tharpa/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.