Thread: Learning Java

Results 1 to 9 of 9
  1. #1
    RebelCoder's Avatar
    Join Date
    Sep 2011
    Gender
    male
    Posts
    26
    Reputation
    10
    Thanks
    6
    My Mood
    Amazed

    Lightbulb Learning Java

    hey guys i just started learning java due to hosting a rsps and no coder

    so i have 2 codes that ive been studying out of a book i need to know if this code could relate to RSPS coding or rsbot scripting

    here is the first code.
    Code:
    import javax.swing.*;
    
    public class TheBasics {
    public static void main( String[] args ){
    JFrame frame = new JFrame( "Hello Basics!");
    JLabel label = new JLabel("Hello, Basics!", JLabel.CENTER);
    frame.add( label );
    frame.setSize( 300, 300);
    frame.setVisible( true );
       }
    }
    here is the second witch has a error that i cant figure out.
    Code:
    import java.awt.*;
    import javax.swing.*;
    
    class HelloComponent extends JComponent {
    	public void paintComponent( Graphics g ) {
    		g.drawString( "Hello, Component!", 125, 95);
    		HelloComponent hello = new HelloComponent();
    		frame.add( hello ); // im pretty sure this is the error havnt double checked tho
    	}
    }
    plz no flaming im here to learn
    -Thanks
    -RebelCoder
    Last edited by RebelCoder; 10-23-2011 at 05:01 PM.

  2. #2
    Saltine's Avatar
    Join Date
    Jun 2011
    Gender
    male
    Posts
    493
    Reputation
    104
    Thanks
    629
    Quote Originally Posted by RebelCoder View Post
    hey guys i just started learning java due to hosting a rsps and no coder

    so i have 2 codes that ive been studying out of a book i need to know if this code could relate to RSPS coding or rsbot scripting

    here is the first code.
    Code:
    import javax.swing.*;
    
    public class TheBasics {
    public static void main( String[] args ){
    JFrame frame = new JFrame( "Hello Basics!");
    JLabel label = new JLabel("Hello, Basics!", JLabel.CENTER);
    frame.add( label );
    frame.setSize( 300, 300);
    frame.setVisible( true );
       }
    }
    here is the second witch has a error that i cant figure out.
    Code:
    import java.awt.*;
    import javax.swing.*;
    
    class HelloComponent extends JComponent {
    	public void paintComponent( Graphics g ) {
    		g.drawString( "Hello, Component!", 125, 95);
    		HelloComponent hello = new HelloComponent();
    		frame.add( hello ); // im pretty sure this is the error havnt double checked tho
    	}
    }
    plz no flaming im here to learn
    -Thanks
    -RebelCoder
    They could definitely relate. A JFrame is simply the swing component which represents a window. This would be necessary to create an RSPS. I would need to see the error specifications to solve the problem with the second snippet.

  3. #3
    RebelCoder's Avatar
    Join Date
    Sep 2011
    Gender
    male
    Posts
    26
    Reputation
    10
    Thanks
    6
    My Mood
    Amazed
    Code:
    warning 1:
    Build path specifies execution environment JavaSE-1.6. There are no JREs installed in the workspace that are strictly compatible with this environment. 	Learning Java		Build path	JRE System Library Problem
    but cause of this error it wont let me compile

  4. #4
    Saltine's Avatar
    Join Date
    Jun 2011
    Gender
    male
    Posts
    493
    Reputation
    104
    Thanks
    629
    Quote Originally Posted by RebelCoder View Post
    Code:
    warning 1:
    Build path specifies execution environment JavaSE-1.6. There are no JREs installed in the workspace that are strictly compatible with this environment. 	Learning Java		Build path	JRE System Library Problem
    but cause of this error it wont let me compile
    I would recommend using an IDE as opposed to performing command line compilation. This is much easier. Simple IDE's include Eclipse, or JCreator. A more advanced one is Netbeans. I would recommend using JCreator, as it requires you to learn correct syntax.
    Download it here:
    JCreator — Java IDE

  5. #5
    john404's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Posts
    352
    Reputation
    69
    Thanks
    842
    My Mood
    Doh
    Quote Originally Posted by Saltine View Post

    I would recommend using an IDE as opposed to performing command line compilation. This is much easier. Simple IDE's include Eclipse, or JCreator. A more advanced one is Netbeans. I would recommend using JCreator, as it requires you to learn correct syntax.
    Download it here:
    JCreator — Java IDE
    Tbh Eclipse is the easiest one to develop in for newcomers.

    Quote Originally Posted by RebelCoder View Post
    Code:
    warning 1:
    Build path specifies execution environment JavaSE-1.6. There are no JREs installed in the workspace that are strictly compatible with this environment. 	Learning Java		Build path	JRE System Library Problem
    but cause of this error it wont let me compile
    > Download Eclipse
    > Switch JavaSE to 1.6

    If not look to install 1.6

  6. #6
    Decieved-'s Avatar
    Join Date
    Apr 2011
    Gender
    male
    Posts
    121
    Reputation
    23
    Thanks
    271
    My Mood
    Lurking
    Quote Originally Posted by Saltine View Post

    I would recommend using an IDE as opposed to performing command line compilation. This is much easier. Simple IDE's include Eclipse, or JCreator. A more advanced one is Netbeans. I would recommend using JCreator, as it requires you to learn correct syntax.
    Download it here:
    JCreator — Java IDE
    Im being taught Java with NetBeans, Hardly Advanced...Its quite simple

  7. #7
    Saltine's Avatar
    Join Date
    Jun 2011
    Gender
    male
    Posts
    493
    Reputation
    104
    Thanks
    629
    Quote Originally Posted by Decieved- View Post
    Im being taught Java with NetBeans, Hardly Advanced...Its quite simple
    I simply meant it has a much larger amount of features. For small projects, all you need is JCreator. To manage a large project with hundreds of files and millions of lines of code, Netbeans ftw.

  8. #8
    Decieved-'s Avatar
    Join Date
    Apr 2011
    Gender
    male
    Posts
    121
    Reputation
    23
    Thanks
    271
    My Mood
    Lurking
    I use Netbeans for everything...Regardless of size. xD

  9. #9
    Takari's Avatar
    Join Date
    Feb 2010
    Gender
    male
    Location
    Cross Fire Section
    Posts
    11,889
    Reputation
    574
    Thanks
    1,966
    My Mood
    Cool
    We use JCreator in school .
    I believe that the first piece of code is one of the basic codes .
    You're making sort of a window.

    You can use something like this too :
    class FirstProgram {

    public static void main (String args[]) {
    System.out.println("Hello World");
    }
    }
    [IMG]https://i1114.photobucke*****m/albums/k538/ImminentJM/takari.png[/IMG]




     
    Goal:
    10,000 Posts - 10/13/2011
    Become Minion - Not Done
    Become Donator - 07/29/2011
    1000 Thanks - Done - 07/25/2011
    2000 Thanks - Not Done
    Thanks Archangel for my 1,000 Thanks.
    Thanks Keroaplt for my Signature.

Similar Threads

  1. Should I learn java?
    By blindman457 in forum Java
    Replies: 23
    Last Post: 03-23-2013, 03:28 AM
  2. Learning C++ and Java Programming
    By MyLazySundays in forum Combat Arms Coding Help & Discussion
    Replies: 3
    Last Post: 10-18-2011, 05:10 PM
  3. Java worthwhile learning?
    By Unknown-C in forum Java
    Replies: 17
    Last Post: 06-04-2011, 06:42 AM
  4. Is it worth learning java?
    By _-Blazin-_ in forum Java
    Replies: 10
    Last Post: 10-28-2010, 08:55 PM
  5. Where could I learn C++? (Beginner, and Advanced stuff)
    By TsumikiriX in forum C++/C Programming
    Replies: 8
    Last Post: 07-19-2006, 08:11 PM