This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#26 2011-11-05 09:49:41

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: Java Official Topic

That's... A lot of posts.  tongue

Just look on the MCForums, or Mod Central when it has some tuts. TS, you want to help me make some?


http://i46.tinypic.com/dw7zft.png

Offline

 

#27 2011-11-05 09:51:15

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Java Official Topic

gbear605 wrote:

maxskywalker wrote:

poopo wrote:

class hi {
    public static void main(String args[]) {
        System.out.println("I know a bit of Java");
    }
}

import javax.swing.JOptionPane;
class HiAndAppletTrouble {
    public static void main(String args[]) {
        JOptionPane.showMessageDialog(null, "Me too.  I like these pop-up messages!");
        JOptionPane.showMessageDialog(null, "I code in Notepad/TextEdit!");
        JOptionPane.showMessageDialog(null, "But when I try to run applets, I get an error message saying something like 'error in method main: no method called main'.  It's weird.");
        System.out.println("Help is appreciated.");
    }
}

The class needs to be named the same thing as the file.

My version of that:
I make javatest.java

Code:

import javax.swing.JOptionPane;
class javatest {
    public static void main(String args[]) {
        JOptionPane.showMessageDialog(null, "Me too.  I like these pop-up messages!");
        JOptionPane.showMessageDialog(null, "I code in Notepad/TextEdit!");
        JOptionPane.showMessageDialog(null, "But when I try to run applets, I get an error message saying something like 'error in method main: no method called main'.  It's weird.");
        System.out.println("Help is appreciated.");
    }
}

I navigate to the javatest.java file in terminal (console)
I run in terminal (console) to make the class file:

Code:

javac javatest.java

Then I run in console to launch the program (you could also double click the .class on some OS's)

Code:

java javatest

Code:

import javax.swing.JOptionPane;
class ThatsWhatIDo {
    public static void main(String args[]) {
        JOptionPane.showMessageDialog(null, "I know.  I do.  I've made a calculator that I use all the time.");
        JOptionPane.showMessageDialog(null, "But when I try to make an Applet, that's what it says when I run it.");
    }
}

Applet.java:

Code:

import java.awt.*;
import javax.swing.*;

class Applet {
    public void Applet (Graphics g) { //I've also called it main
        super.paint(g);
        g.drawString("Hello World!", 25, 25);
    }
}

And then in command line:

Code:

javac Applet.java
java Applet

Offline

 

#28 2011-11-05 10:19:58

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Java Official Topic

Harakou wrote:

ipodbiped wrote:

WindowsExplorer wrote:

Does JavaScript count?

Java. JavaScript. Its all the same to me.

Java and JavaScript are completely different languages. They share some syntax, but they're similar only in name.

In fact, JavaScript was originally called ECMAScript!

Offline

 

#29 2011-11-06 12:25:12

ipodbiped
Scratcher
Registered: 2011-02-06
Posts: 1000+

Re: Java Official Topic

Bump

Offline

 

#30 2011-11-06 18:07:28

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Java Official Topic

ipodbiped wrote:

Bump

You heard the man/girl/asexual-being!  Bump!

Offline

 

#31 2011-11-19 10:58:27

ipodbiped
Scratcher
Registered: 2011-02-06
Posts: 1000+

Re: Java Official Topic

I'm going to try (and probably fail) at making a Java web browser.

Offline

 

#32 2011-11-20 02:14:15

veggieman001
Scratcher
Registered: 2010-02-20
Posts: 1000+

Re: Java Official Topic

Wicki hates it


Posts: 20000 - Show all posts

Offline

 

#33 2011-11-20 13:34:10

throughthefire
Scratcher
Registered: 2009-07-09
Posts: 1000+

Re: Java Official Topic

I know some Java, but not enough to really make a full fledged game.


Back. For now. Maybe.

Offline

 

#34 2011-11-20 17:33:46

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Java Official Topic

throughthefire wrote:

I know some Java, but not enough to really make a full fledged game.

Same here.  I can ALMOST make a simple attack/magic/shield game, though (lacking random numbers, and I'm sure I've got an old thread about it somewhere in Python, try the keywords Python, Game, Simple Game in Python, etc).

Offline

 

#35 2011-11-20 17:36:28

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Java Official Topic

maxskywalker wrote:

throughthefire wrote:

I know some Java, but not enough to really make a full fledged game.

Same here.  I can ALMOST make a simple attack/magic/shield game, though (lacking random numbers, and I'm sure I've got an old thread about it somewhere in Python, try the keywords Python, Game, Simple Game in Python, etc).

You're looking for a random number generator in Java?


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#36 2011-11-20 17:46:38

cocolover76
Scratcher
Registered: 2011-10-09
Posts: 500+

Re: Java Official Topic

Harakou wrote:

WindowsExplorer wrote:

I, how do I put this eh, don't think we need this topic...

Why not? I don't see a ton of Java discussion on Misc, but there's nothing really wrong with this topic. Like other "official topics" for less-discussed subjects, it'll die if there's no interest, and if it doesn't die, then it has a purpose.  smile

Harakou, can you move this to Advanced Topics?
Java is advanced, and is a programming language.


http://i.imgur.com/HfEPZ.gifhttp://i.imgur.com/pvKb6.png

Offline

 

#37 2011-11-21 09:33:58

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Java Official Topic

cocolover76 wrote:

Harakou wrote:

WindowsExplorer wrote:

I, how do I put this eh, don't think we need this topic...

Why not? I don't see a ton of Java discussion on Misc, but there's nothing really wrong with this topic. Like other "official topics" for less-discussed subjects, it'll die if there's no interest, and if it doesn't die, then it has a purpose.  smile

Harakou, can you move this to Advanced Topics?
Java is advanced, and is a programming language.

But it's not related to Scratch, so it belongs in Misc.  Most of the time, when someone posts something like this in Advanced, it gets closed.

Offline

 

#38 2011-11-21 09:35:24

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Java Official Topic

Harakou wrote:

maxskywalker wrote:

throughthefire wrote:

I know some Java, but not enough to really make a full fledged game.

Same here.  I can ALMOST make a simple attack/magic/shield game, though (lacking random numbers, and I'm sure I've got an old thread about it somewhere in Python, try the keywords Python, Game, Simple Game in Python, etc).

You're looking for a random number generator in Java?

Yeah.  I don't really understand the random thing.  I'm searching for a thenewboston random number tutorial.  I couldn't figure out how to get user input until I found out about java.util.scanner either.

Offline

 

#39 2011-11-21 19:13:58

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Java Official Topic

maxskywalker wrote:

Harakou wrote:

maxskywalker wrote:

Same here.  I can ALMOST make a simple attack/magic/shield game, though (lacking random numbers, and I'm sure I've got an old thread about it somewhere in Python, try the keywords Python, Game, Simple Game in Python, etc).

You're looking for a random number generator in Java?

Yeah.  I don't really understand the random thing.  I'm searching for a thenewboston random number tutorial.  I couldn't figure out how to get user input until I found out about java.util.scanner either.

Just use the Math.random() method (returns a double between 0 and 1) or the Random class from the java.util package.

For example, if you wanted to get a random integer from 1 to 10 from the Random class, you would use the nextInt() method, which returns an integer from 0 (inclusive) to the argument provided (exclusive):

Code:

import java.util.Random;

public class Ponies{
    public static void main(String args){
        Random rand = new Random();
        int myRand = rand.nextInt(10) + 1;
    }
}

Remember, the Java Documentation is your friend!


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#40 2011-11-21 19:18:04

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Java Official Topic

Harakou wrote:

maxskywalker wrote:

Harakou wrote:


You're looking for a random number generator in Java?

Yeah.  I don't really understand the random thing.  I'm searching for a thenewboston random number tutorial.  I couldn't figure out how to get user input until I found out about java.util.scanner either.

Just use the Math.random() method (returns a double between 0 and 1) or the Random class from the java.util package.

For example, if you wanted to get a random integer from 1 to 10 from the Random class, you would use the nextInt() method, which returns an integer from 0 (inclusive) to the argument provided (exclusive):

Code:

import java.util.Random;

public class Ponies{
    public static void main(String args){
        Random rand = new Random();
        int myRand = rand.nextInt(10) + 1;
    }
}

Remember, the Java Documentation is your friend!

Okay.  Thanks, Harakou.  Yet again you help me with my code.  How many languages do you know, anyway, if you'll excuse a bit of off topic.

Offline

 

#41 2011-11-21 19:22:29

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Java Official Topic

maxskywalker wrote:

Harakou wrote:

maxskywalker wrote:

Yeah.  I don't really understand the random thing.  I'm searching for a thenewboston random number tutorial.  I couldn't figure out how to get user input until I found out about java.util.scanner either.

Just use the Math.random() method (returns a double between 0 and 1) or the Random class from the java.util package.

For example, if you wanted to get a random integer from 1 to 10 from the Random class, you would use the nextInt() method, which returns an integer from 0 (inclusive) to the argument provided (exclusive):

Code:

import java.util.Random;

public class Ponies{
    public static void main(String args){
        Random rand = new Random();
        int myRand = rand.nextInt(10) + 1;
    }
}

Remember, the Java Documentation is your friend!

Okay.  Thanks, Harakou.  Yet again you help me with my code.  How many languages do you know, anyway, if you'll excuse a bit of off topic.

No problem. I actually don't know that much in regards to variety of languages though: A couple dialects of BASIC, a bit of Python, some Batch, and Java.


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#42 2011-11-21 19:24:02

my-chemical-romance
Scratcher
Registered: 2011-04-24
Posts: 1000+

Re: Java Official Topic

I use Eclipse, what about you guys?

I also made a private mod for MC which adds 2 new items:

Redstonebutton
TNTreceiver

You made the TNT with a TNT block and a redstone torch on top and the button like a minecart using stone, redstone dust in the middle and a torch on top.

Whenever the button is pressed it gives out a signal to prime the TNT so you can put TNT in prime points of your building without loads of complicated wires leading everywhere, once I iron out the bugs and get some pictures for the items (the button is using a stick and the TNT is using the normal TNT) I'll make it all public.

Offline

 

#43 2011-11-21 19:24:26

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Java Official Topic

Harakou wrote:

maxskywalker wrote:

Harakou wrote:


Just use the Math.random() method (returns a double between 0 and 1) or the Random class from the java.util package.

For example, if you wanted to get a random integer from 1 to 10 from the Random class, you would use the nextInt() method, which returns an integer from 0 (inclusive) to the argument provided (exclusive):

Code:

import java.util.Random;

public class Ponies{
    public static void main(String args){
        Random rand = new Random();
        int myRand = rand.nextInt(10) + 1;
    }
}

Remember, the Java Documentation is your friend!

Okay.  Thanks, Harakou.  Yet again you help me with my code.  How many languages do you know, anyway, if you'll excuse a bit of off topic.

No problem. I actually don't know that much in regards to variety of languages though: A couple dialects of BASIC, a bit of Python, some Batch, and Java.

Oh.  And yet you've helped me immensely with two.

Offline

 

#44 2011-11-21 19:30:00

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Java Official Topic

my-chemical-romance wrote:

I use Eclipse, what about you guys?

I also made a private mod for MC which adds 2 new items:

Redstonebutton
TNTreceiver

You made the TNT with a TNT block and a redstone torch on top and the button like a minecart using stone, redstone dust in the middle and a torch on top.

Whenever the button is pressed it gives out a signal to prime the TNT so you can put TNT in prime points of your building without loads of complicated wires leading everywhere, once I iron out the bugs and get some pictures for the items (the button is using a stick and the TNT is using the normal TNT) I'll make it all public.

Sounds cool! I'd love to see it.

And I use Eclipse as well, naturally.  big_smile

maxskywalker wrote:

Harakou wrote:

maxskywalker wrote:


Okay.  Thanks, Harakou.  Yet again you help me with my code.  How many languages do you know, anyway, if you'll excuse a bit of off topic.

No problem. I actually don't know that much in regards to variety of languages though: A couple dialects of BASIC, a bit of Python, some Batch, and Java.

Oh.  And yet you've helped me immensely with two.

I do my best. The important thing is knowing how the languages work. I'm taking a computer science course currently, and although we work in Java, the important part is understanding the concepts. Once you understand that, you can understand pretty much any language based around the same concepts and program with it within a relatively short amount of time.


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#45 2011-11-21 19:39:38

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Java Official Topic

my-chemical-romance wrote:

I use Eclipse, what about you guys?

I also made a private mod for MC which adds 2 new items:

Redstonebutton
TNTreceiver

You made the TNT with a TNT block and a redstone torch on top and the button like a minecart using stone, redstone dust in the middle and a torch on top.

Whenever the button is pressed it gives out a signal to prime the TNT so you can put TNT in prime points of your building without loads of complicated wires leading everywhere, once I iron out the bugs and get some pictures for the items (the button is using a stick and the TNT is using the normal TNT) I'll make it all public.

I use TextEdit.  lol  I never felt I needed an IDE/development environment.

Offline

 

#46 2011-11-22 00:23:12

throughthefire
Scratcher
Registered: 2009-07-09
Posts: 1000+

Re: Java Official Topic

maxskywalker wrote:

poopo wrote:

class hi {
    public static void main(String args[]) {
        System.out.println("I know a bit of Java");
    }
}

import javax.swing.JOptionPane;
class HiAndAppletTrouble {
    public static void main(String args[]) {
        JOptionPane.showMessageDialog(null, "Me too.  I like these pop-up messages!");
        JOptionPane.showMessageDialog(null, "I code in Notepad/TextEdit!");
        JOptionPane.showMessageDialog(null, "But when I try to run applets, I get an error message saying something like 'error in method main: no method called main'.  It's weird.");
        System.out.println("Help is appreciated.");
    }
}

You use Notepad/Textedit? An IDE would really help, especially in debugging and such. I recommend either Notepad++ or Eclipse (Notch himself programs using the latter).


Back. For now. Maybe.

Offline

 

#47 2011-11-22 00:53:56

nightmarescratcher
Scratcher
Registered: 2011-10-10
Posts: 1000+

Re: Java Official Topic

I don't like Java...


http://fc07.deviantart.net/fs70/f/2011/171/f/3/derpy_hooves_derp_sig_by_alicehumansacrifice1-d3jg613.png

Offline

 

#48 2011-11-22 10:10:47

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Java Official Topic

throughthefire wrote:

maxskywalker wrote:

poopo wrote:

class hi {
    public static void main(String args[]) {
        System.out.println("I know a bit of Java");
    }
}

import javax.swing.JOptionPane;
class HiAndAppletTrouble {
    public static void main(String args[]) {
        JOptionPane.showMessageDialog(null, "Me too.  I like these pop-up messages!");
        JOptionPane.showMessageDialog(null, "I code in Notepad/TextEdit!");
        JOptionPane.showMessageDialog(null, "But when I try to run applets, I get an error message saying something like 'error in method main: no method called main'.  It's weird.");
        System.out.println("Help is appreciated.");
    }
}

You use Notepad/Textedit? An IDE would really help, especially in debugging and such. I recommend either Notepad++ or Eclipse (Notch himself programs using the latter).

I don't know who Notch is.  I really just don't feel the need.  I type with accuracy, and when I get a bug, Terminal gives me a useful error message so that I can fix my program instantly.  The only useful thing might be running applets more easily, but I really don't mind.  I tried to download Eclipse once.  It said my Mac didn't know how to open the installer.

Offline

 

#49 2011-11-22 10:13:21

veggieman001
Scratcher
Registered: 2010-02-20
Posts: 1000+

Re: Java Official Topic

maxskywalker wrote:

throughthefire wrote:

maxskywalker wrote:


import javax.swing.JOptionPane;
class HiAndAppletTrouble {
    public static void main(String args[]) {
        JOptionPane.showMessageDialog(null, "Me too.  I like these pop-up messages!");
        JOptionPane.showMessageDialog(null, "I code in Notepad/TextEdit!");
        JOptionPane.showMessageDialog(null, "But when I try to run applets, I get an error message saying something like 'error in method main: no method called main'.  It's weird.");
        System.out.println("Help is appreciated.");
    }
}

You use Notepad/Textedit? An IDE would really help, especially in debugging and such. I recommend either Notepad++ or Eclipse (Notch himself programs using the latter).

I don't know who Notch is.  I really just don't feel the need.  I type with accuracy, and when I get a bug, Terminal gives me a useful error message so that I can fix my program instantly.  The only useful thing might be running applets more easily, but I really don't mind.  I tried to download Eclipse once.  It said my Mac didn't know how to open the installer.

You probably downloaded the Windows installer then...


Posts: 20000 - Show all posts

Offline

 

#50 2011-11-22 10:18:36

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Java Official Topic

maxskywalker wrote:

I don't know who Notch is.  I really just don't feel the need.  I type with accuracy, and when I get a bug, Terminal gives me a useful error message so that I can fix my program instantly.  The only useful thing might be running applets more easily, but I really don't mind.  I tried to download Eclipse once.  It said my Mac didn't know how to open the installer.

Even syntax highlighting is a reason to get an IDE.


http://block.site90.net/scratch.mit/text.php?size=30&text=%20A%20signature!&color=333333

Offline

 

Board footer