Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Java (http://www.programmingforums.org/forum17.html)
-   -   can't compile code (http://www.programmingforums.org/showthread.php?t=6237)

lloydkirk Oct 4th, 2005 12:28 AM

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 ();
 
     
  }

}
}


tempest Oct 4th, 2005 12:46 AM

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)

bl00dninja Oct 4th, 2005 2:18 AM

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
:

;

tempest Oct 4th, 2005 2:43 AM

I compiled it on my machine, no compiler error...

BinaryStorm Oct 4th, 2005 4:16 AM

Me too. I used VS.NET 2003, Java.

InfoGeek Oct 4th, 2005 5:00 AM

He prolly don't have a compiler or don't know how to invoke it.

lloydkirk Oct 4th, 2005 12:50 PM

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?

stevengs Oct 4th, 2005 12:54 PM

Would you run an .exe that someone you don't know mailed to you???

Polyphemus_ Oct 4th, 2005 12:57 PM

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.

lloydkirk Oct 4th, 2005 1:04 PM

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.


All times are GMT -5. The time now is 5:36 AM.

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