Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (541)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Newbie & Debugging Questions / Re: Reading HTML on: 2006-03-14 01:36:06
Hi Cylab,

Wow.  Thanks for all of the information.  I will definitely consider it. - possibly the last option.

I was mistaken about the problem with netbeans.  It actually appears to run.  However, when it gets to the point of actually installing the program to a directory, it gets an error:  "Error: C:\Netbeans is not writable"  It does this with any directory I choose or create. 

I think this is a I'm running on a crippled version of Windows problem.  I'm not going to reinstall Windows again, because I've probably done it 3 times since I've owned this version of Windows, and it's just too much trouble.    ----Plus working 3rd shift now it makes it difficult to get anything done...... Sad )
I'm going to wait until I get a new computer.

Well, thanks for all of your help guys.

And, I'm sure I'll have more questions in the future....lol.

Rick
2  Game Development / Newbie & Debugging Questions / Re: Reading HTML on: 2006-03-13 14:58:28
Hi Cylab,

Thanks for the input.  Yes, I would like to use an IDE.  I actually read the thread 3 weeks ago, a month or more or something about where to start.  And, I actually downloaded netbeans as this seemed to be maybe a little favored over eclipse.  Although a lot of people liked eclipse too.  I looked at it as well.

Unfortuanetly, I'm still running Windows 98 (I'll explain in a sec.), and after I downloaded netbeans and tried to run it, it would not run.  And, eclipse, looking like a good contender, is a huge download - maybe 100MB or more?  Can't remember.  And unfortuanetly, again, I have satellite service, and you know - they have the fair use policy crap - which is good.   

Why am I still running Windows 98 SE?  Because I can't justify paying a $100 or more on a new operating system, when I could upgrade my computer for probably a couple hundred more.  Why haven't I upgraded my computer?  Because I've been professionly unemployed now (because I was burned out) for over a couple years now and funds are kind of tight.

Anyway, I guess my real question is that when you create a stand-alone application, will it be a true stand-alone application not requiring any extra java files?  In other words, will it be an .exe?
3  Game Development / Newbie & Debugging Questions / Re: Reading HTML on: 2006-03-13 03:16:02
1.  Ahhh, thanks, ok!  Did that.

2.  Yes, deleted that.  That might rectify some of my other Windows problems.

3.  And, yes retyped it as you have quoted.

Quote
Paste that into a command line window (in the correct directory!) and I guarantee it will work. (BTW, wasn't the name URLConnection1 and not URLConnections1?)

No, actually, it is URLConnections1.  The original example is URLConnections; however, I copied it over to my working directory and modified while I wa trying to solve this problem before- so I just copied the original back over and called it URLConnections1 just to see if it would compile.

I have really been interested in java lately and if I can develop stand alone applications that are comparable to a Windows application than that is the way I would like to start.  I actually have a copy of Windows Visual C++ 6.0, but just never pursued Windows programming seriously.

Well, I retyped it as you said and got the Malformed URL error again.....

BUT, I went and looked at the code, and I put the http:// in front of the www.yahoo.com and recompiled it, and then ran it and it worked!!

Now, do you typically create stand-alone java applications?  Is this a common practice?

Well, I have to go to work now...  Sad  I work 3rd shift.  Yuck!   Sad 

Thanks for all of your help, j!

Rick
4  Game Development / Newbie & Debugging Questions / Re: Reading HTML on: 2006-03-13 00:01:55
Hi Jeff,

No.  (Boy, I feel stupid).  I just now typed and got:

1  
2  
3  
4  
C:\Java_2>java -cp c:\j2sdk1.1.1_01\lib URLConnections1.java
Exception in thread "main" java.lang.NoClassDefFoundError: URLConnections1/java

C:\Java_2>

The URLConnections1.java and .class files are located in the Java_2 directory.

I guess that's the pre- Sunday nap before work thoughtlessness.  Wink

Do you think there's not enough stuff imported??  It's actually compiling so it's finding the bin folder alright.

That's the only thing I can think of....

P.S.  I'm hoping to make this and possibly other stuff a stand alone application - Can you guys/ Do you guys recommend developing java applications and making them standalone via another application or would you recommend just using Windows, in which case that would open up another ball of wax?

-Rick
5  Game Development / Newbie & Debugging Questions / Re: Reading HTML on: 2006-03-12 18:43:59
Nope, that didn't help.

I think there is something wrong with the classpath stuff, because I made a change a while ago here, and now when windows starts up, it can't find win.com in the windows directory, and I always have to change it to the Windows directory and type win.  I'm still running Windows 98, BTW.
Here's what the paths look like.  Tell me if you can see something obvious.  I can't right away.:
6  Game Development / Newbie & Debugging Questions / Re: Reading HTML on: 2006-03-12 18:29:19
Hello jbanes,

Thanks for your reply.  Yeha, I was thinking the same thing about applets.

Anyway, when I run the application using the -cp switch, I get the following (running it in the directory of URLConnections1):
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
 -hotspot      is a synonym for the "client" VM  [deprecated]
               The default VM is client.

 -cp -classpath <directories and zip/jar files separated by ;>
               set search path for application classes and resour
 -D<name>=<value>
               set a system property
 -verbose[:class|gc|jni]
               enable verbose output
 -version      print product version and exit
 -showversion  print product version and continue
 -? -help      print this help message
 -X            print help on non-standard options
 -ea[:<packagename>...|:<classname>]
 -enableassertions[:<packagename>...|:<classname>]
               enable assertions
 -da[:<packagename>...|:<classname>]
 -disableassertions[:<packagename>...|:<classname>]
               disable assertions
 -esa | -enablesystemassertions
               enable system assertions
 -dsa | -disablesystemassertions
               disable system assertions

I assume it didn't like something as I couldn't see the top.  Darn it!

And, when I run it (within the directory) without the -cp switch, I get........
1  
2  
3  
4  
5  
6  
7  
8  
9  
C:\Java_2>java URLConnections1
Exception in thread "main" java.net.MalformedURLException: no protocol: www.yaho
o.com
        at java.net.URL.<init>(URL.java:579)
        at java.net.URL.<init>(URL.java:476)
        at java.net.URL.<init>(URL.java:425)
        at URLConnections1.main(URLConnections1.java:11)

C:\Java_2>

I wonder if it is some of the classpath crap.....

Going to try something and restart Windows.....

Rick
7  Game Development / Newbie & Debugging Questions / Reading HTML on: 2006-03-12 13:51:34
Hello All,

I'm not totally new to Java.  I've been messing around with it for the past couple of years.
Not until the past couple of months have I decided to become serious about it.


Which leads me to my question.  I've mostly only done stuff with graphics and some controls here and there, but now I have come across an apllication where I need to read HTML, perform operations on it, and store it in a text box or something where I can copy it to the clipboard.  However, I am stuck on step 1 - actually reading the file.

Here is my code thus far in applet form:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
import java.applet.*;
import java.io.*;
import java.net.*;
import java.awt.*;
import java.util.*;
import java.lang.Math;
import java.util.Date;
import java.util.Random;
import java.awt.event.*;
import java.applet.AudioClip;


public class myAppletIO extends java.applet.Applet {


URL myURL;
URL url;


URLConnection urlconnection;
InputStream myIS;
String yep = "wrtjwhrtkj:";

public void init() {

   String s;
   setBackground(Color.yellow);
   setForeground(Color.blue);
   yep.concat("Hello!");
   String inputLine;  
   DataInputStream inStream;



        URLConnection connection;
       
   //Step 1&2: Create URL and URLConnection instances
   try{
      url = new URL("www.yahoo.com");
   }catch(MalformedURLException e) {yep.concat("Can't access URL");
///               yep.concat("String: " + e.toString());
      System.out.println("String: " + e.toString());
//                yep.concat("Message: " + e.getMessage());
      System.out.println("Message: " + e.getMessage());
                repaint();}

/*
   try{
      myURLConnection = url.openConnection();//
   }catch(IOException e) {System.out.println("Can't open connection to URL");
                       yep.concat("Can't open connection to URL"); repaint();}
*/


   //Step 3: Get InputStream associated with URLConnection
/*   try {
      myIS = myURLConnection.getInputStream();      
   }
                    catch(IOException e) {System.out.println("Can't open connection to URL");}
*/


   //STEP A
 //                   InputStreamReader myISR = new InputStreamReader(myIS);

   //STEP B
 //                   BufferedReader BR = new BufferedReader(myISR);




/*                  for(int i=0; i<3; i++)
                    {

      try {               
                s = BR.readLine();
                System.out.println("Line " + i + ": " + s);
      }catch(IOException e) {System.out.println("Line " + i + ": " + s);}
                    }

                    repaint();
                   //Close all streams
                    try{
           BR.close();
           myISR.close();             
      myIS.close();
   } catch(IOException e) {yep.concat("can't close streams"); }
*/
}
    public void paint(Graphics g) {
       
          g.drawString(yep,60,100);

   
    }         



}


I guess my first question would be:  Can this be done with an applet? 

As is, the applet compiles and runs successfully.  However, when the second and / or third try blocks are uncommented, the code compiles successfully, however when it is run, the applet won't init or I get the applet area box with the red X in it.

I also tried an application thinking that this might be an applet limitation thing (this is an example from a book):
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
import java.io.*;
import java.net.*;
import java.util.Date;

class URLConnections1
{
    public static void main(String args[]) throws Exception
    {
        int character;
       
        URL url = new URL("www.yahoo.com");
        URLConnection urlconnection = url.openConnection();

        System.out.println("Content type: " +
            urlconnection.getContentType());
        System.out.println("Document date: " +
            new Date(urlconnection.getDate()));
        System.out.println("Last modified: " +
            new Date(urlconnection.getLastModified()));
        System.out.println("Document expires: " +
            urlconnection.getExpiration());
       
        int contentlength = urlconnection.getContentLength();

        System.out.println("Content length: " + contentlength);

        if (contentlength > 0) {
            InputStream in = urlconnection.getInputStream();

            while ((character = in.read()) != -1) {
                System.out.print((char) character);
            }

            in.close();
        }
    }
}


However, when I run this after I compile it, I get a
Quote
"Exception in thread "main" java.lang.NoCclassDefFoundError:  URLConnections1

The java version I'm using is 1.4.0 and sometimes 1.4.1.  I've looked at many examples and consulted the book I've been studying from, Java 2 Black Book (which the app example came from), but I just can't seem to get past this. 

If anybody would have any suggestions or input, I'd really appreciate it.

Thanks,

Rick
Pages: [1]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Mr.CodeIt (24 views)
2014-12-23 03:34:11

rwatson462 (54 views)
2014-12-15 09:26:44

Mr.CodeIt (45 views)
2014-12-14 19:50:38

BurntPizza (85 views)
2014-12-09 22:41:13

BurntPizza (110 views)
2014-12-08 04:46:31

JscottyBieshaar (79 views)
2014-12-05 12:39:02

SHC (89 views)
2014-12-03 16:27:13

CopyableCougar4 (97 views)
2014-11-29 21:32:03

toopeicgaming1999 (155 views)
2014-11-26 15:22:04

toopeicgaming1999 (153 views)
2014-11-26 15:20:36
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!