Web Analytics Made Easy -
StatCounter I have a Java file I need to execute it - CodingForum

Announcement

Collapse
No announcement yet.

I have a Java file I need to execute it

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • I have a Java file I need to execute it

    hi my first post, im a jarva n00b.I have some code and saved the file as a "Java Language Source file", I want to execute it so I can see if the bot actaully works, how do I do this?

    thanks


    My code
    PHP Code:
    import org.jibble.pircbot.*;

    public class 
    MyBot extends PircBot {
        
        public 
    MyBot() {
            
    this.setName("MyBot");
        }
        
    }
    // JavaScript Document
    import org.jibble.pircbot.*;

    public class 
    MyBotMain {
        
        public static 
    void main(String[] argsthrows Exception {
            
            
    // Now start our bot up.
            
    MyBot bot = new MyBot();
            
            
    // Enable debugging output.
            
    bot.setVerbose(true);
            
            
    // Connect to the IRC server.
            
    bot.connect("irc.freenode.net");

            
    // Join the #pircbot channel.
            
    bot.joinChannel("#pircbot");
            
        }
        
    }
    import org.jibble.pircbot.*;

    public class 
    MyBot extends PircBot {
        
        public 
    MyBot() {
            
    this.setName("MyBot");
        }
        
        public 
    void onMessage(String channelString sender,
                           
    String loginString hostnameString message) {
            if (
    message.equalsIgnoreCase("time")) {
                
    String time = new java.util.Date().toString();
                
    sendMessage(channelsender ": The time is now " time);
            }
        }


  • #2
    java != javascript

    Comment


    • #3
      thanks for the post^, i have no idea what it you mean though lol, sorry im new to this.


      when I click on the file, it opens with MS VS2005 for some reasons too.
      Last edited by bg1; Apr 13, 2009, 03:19 PM.

      Comment


      • #4
        @bg1> This is not the Java forum, this is the JavaScript forum. Different programming language altogether. You want to go here.

        Looks like for some reason you think you've got a bit of JavaScript code there, you don't. It's Java.

        BTW, you have defined two public classes in the same file; make sure the classes 'MyBotMain' and 'MyBot' are put in two different files. Check the links above for more Java programming help.

        Comment


        • #5
          Originally posted by bg1 View Post
          thanks for the post^, i have no idea what it you mean though lol, sorry im new to this.


          when I click on the file, it opens with MS VS2005 for some reasons too.
          "!=" means not equal to. hence, javascript is not equal to java. java is a server side language, javascript is client side web language

          Comment

          Working...
          X