Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 3rd, 2005, 11:28 PM   #1
lloydkirk
Newbie
 
Join Date: Oct 2005
Posts: 7
Rep Power: 0 lloydkirk is on a distinguished road
can't compile code

A friend of mine gave me some java code and some basic directions. Unfortunately, I can't get it to compile or execute. I would realy appreciate it if you guys could help me out. Im an absolute newb when it comes to java. :o
Maybe someone could compile it for me. Also, when he says to "run it with java VS 'id number', how is that done and where is it executed? Im guessing its supposed to be typed in the command prompt, but im not sure of the directory...Thanks for your help!


Directions
Quote:
Go to http://www.84silver.com/contest_browse_finals.php and select a calculator to vote for. The 'calculator ID' is shown at the end of the URL, eg 411 for Washington. Extract the code to 'VS.java' (case matters). Compile the code, and run it with java VS 'id number'.

eg

java VS 1161

to vote for Florida. 1 or 2 votes are cast per second.

Code:

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

public class VS{


   public static void main(String[] args) throws Exception{
      
   String calcID;
   
   
   System.out.print("\n***TI Vote-stuffer**\n");

   if(args.length==0){
   
         System.out.print("\n\nPlease enter a calculator-ID to vote for");   

         System.out.print("\nas a parameter! eg 'java VS 123'");
         System.out.print("\nyou may find the ID by clicking on an entry on TI's web site");
         return;
   }

   calcID=args[0];   
   System.out.print("\n\nUsing calculator ID: " + calcID+"\n\n");
   
       URL                 url;
    URLConnection urlConn;
    DataOutputStream    printout;
    DataInputStream     input;
   
    while(true){
   
    Thread.sleep(500);
   
    // URL of CGI-Bin script.
    url = new URL ("http://www.84silver.com/contest_vote_finals.php");
    // URL connection channel.
    urlConn = url.openConnection();
    // Let the run-time system (RTS) know that we want input.
    urlConn.setDoInput (true);
    // Let the RTS know that we want to do output.
    urlConn.setDoOutput (true);
    // No caching, we want the real thing.
    urlConn.setUseCaches (false);
    // Specify the content type.
    urlConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
    // Send POST output.
    printout = new DataOutputStream (urlConn.getOutputStream ());
    String content =


//"calculator_id=" + URLEncoder.encode ("1161") +
"calculator_id=" + URLEncoder.encode (calcID) +
"&vote_for_this_one=" + URLEncoder.encode ("Vote!");
    printout.writeBytes (content);
    printout.flush ();
    printout.close ();
    // Get response data.
    input = new DataInputStream (urlConn.getInputStream ());
    String str;
    while (null != ((str = input.readLine())))

{

System.out.println (str);

}
    input.close ();
   
      
   }

}
}
lloydkirk is offline   Reply With Quote
Old Oct 3rd, 2005, 11:46 PM   #2
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 5 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
Save the code in a file named "VS.java" and then type the following command:

javac VS.java

The following code runs it:

java VS (calc_id)
__________________

tempest is offline   Reply With Quote
Old Oct 4th, 2005, 1:18 AM   #3
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5 bl00dninja is on a distinguished road
i could compile this for you, but it would do about as much good as if i took a piss for you, in other words, none. i'm not going to try to send or link to or upload any .exe files onto anything. compiling is the fun part when you get to hunt down your mistakes. (for the first half-hour)...after 30 minutes compiling is no longer fun. more like slamming your nuts in a sliding glass door. here's the secret though...for most compile errors there are two answers...

either
or
__________________
i put on my robe and wizard hat...

Have you ever heard of Plato, Aristotle, Socrates?...Morons.
bl00dninja is offline   Reply With Quote
Old Oct 4th, 2005, 1:43 AM   #4
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 5 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
I compiled it on my machine, no compiler error...
__________________

tempest is offline   Reply With Quote
Old Oct 4th, 2005, 3:16 AM   #5
BinaryStorm
Programmer
 
BinaryStorm's Avatar
 
Join Date: Sep 2005
Location: Požega, Croatia
Posts: 93
Rep Power: 3 BinaryStorm is on a distinguished road
Me too. I used VS.NET 2003, Java.
__________________
1001 1101 1001 1110 0101 1102 ?! AAAAARRGGHHH
_____________________
Free&Premium Web hosting reviews. Click here!
Money making oasis. Run your own home based biz.
BinaryStorm is offline   Reply With Quote
Old Oct 4th, 2005, 4:00 AM   #6
InfoGeek
Professional Programmer
 
InfoGeek's Avatar
 
Join Date: Jun 2005
Location: India, The great.
Posts: 435
Rep Power: 4 InfoGeek is on a distinguished road
He prolly don't have a compiler or don't know how to invoke it.
__________________
PFO - My daily dose of technology.
InfoGeek is offline   Reply With Quote
Old Oct 4th, 2005, 11:50 AM   #7
lloydkirk
Newbie
 
Join Date: Oct 2005
Posts: 7
Rep Power: 0 lloydkirk is on a distinguished road
I got these errors:
Note: VS.java uses or overides a depreciated api
Recompile with -Xlint: depreciation for details.

Can someone just e-mail the .exe file to me please?

Quote:
Originally Posted by tempest
Save the code in a file named "VS.java" and then type the following command:

javac VS.java

The following code runs it:

java VS (calc_id)
Where are those commands written?
lloydkirk is offline   Reply With Quote
Old Oct 4th, 2005, 11:54 AM   #8
stevengs
Professional Programmer
 
stevengs's Avatar
 
Join Date: May 2005
Location: Bad Nauheim, Germany
Posts: 436
Rep Power: 4 stevengs is on a distinguished road
Would you run an .exe that someone you don't know mailed to you???
__________________
-Steven
"Is this a piece of your brain?" - Basil Fawlty
stevengs is offline   Reply With Quote
Old Oct 4th, 2005, 11:57 AM   #9
Polyphemus_
Expert Programmer
 
Polyphemus_'s Avatar
 
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 3 Polyphemus_ is on a distinguished road
Quote:
Originally Posted by lloydkirk
I got these errors:
Note: VS.java uses or overides a depreciated api
Recompile with -Xlint: depreciation for details.
that is no error, neither a warning. It is just a note.
Polyphemus_ is offline   Reply With Quote
Old Oct 4th, 2005, 12:04 PM   #10
lloydkirk
Newbie
 
Join Date: Oct 2005
Posts: 7
Rep Power: 0 lloydkirk is on a distinguished road
Quote:
Originally Posted by stevengs
Would you run an .exe that someone you don't know mailed to you???

Yes, you guys seem nice enough. Norton takes care of most malicious programs anyways.
lloydkirk is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:05 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC