• Welcome to Valhalla Legends Archive.
 

Creating Programs in JCreator LE

Started by j0k3r, December 06, 2003, 09:05 AM

Previous topic - Next topic

j0k3r

I've been trying to get started on Java, but I've bene unable to because of the confusion of the Java compilers (or maybe I'm just stupid). When I open JCreator LE, it gives me a .html and a .class file, I know you embed the Java file into an HTML document, but that's about it. I can't run the program to see how it works, I can't do anything with it except write (incorrect) code.

Can somebody explain to me how to go about creating Java files/applets?
QuoteAnyone attempting to generate random numbers by deterministic means is, of course, living in a state of sin
John Vo

Banana fanna fo fanna

Don't write applets. They are a waste of time. You want to create a new Java Application, which will give you a familiar .java file with a main() method.

j0k3r

Right, I don't know the difference, and google is hating me today. If you just create a java file, will it only output whatever it does once? I was under the impression you could make games through java, and have it run constantly...

Oh well, more googling to do.
QuoteAnyone attempting to generate random numbers by deterministic means is, of course, living in a state of sin
John Vo

Banana fanna fo fanna


j0k3r

Quote from: St0rm.iD on December 06, 2003, 12:24 PM
Yes, you can. Write a loop :)
So it can do either? Alright I know how those kind of languages work, but why wouldn't I want to make an application?
QuoteAnyone attempting to generate random numbers by deterministic means is, of course, living in a state of sin
John Vo

Banana fanna fo fanna

You can write an application, which is...an application.
You can write an applet, which is a sad flash competitor.
You can write a JSP, which is ASP with Java.
You can write a servlet, which is a powerful web language thing.

Hostile

Java can make applications... quite well actually. :P
Applets were basically Java's first attempt to get on the web, they still work best for applications over webbrowsers where there needs to be client side interaction mainly, like games. For serverside they made Servlets or java server pages which includes the servlet classes and allows you to embed java code in an html page (which is a .jsp file and is compiled by the application/web server into the java bytecode. This however lacks clientside interaction in which for most cases, in things like browser commands you would use javascript or for tools, enterprise java beans.) If what you're looking to do is right a standalone program with a GUI per say or even with applets with a GUI you will want to learn in addition to java coding, the classes for AWT or the newer/better Swing classes. If you need an API reference then there are plenty of javadocs created for it, goto java.sun.com and click on the API link, theres reference for all core java classes and its extentions, with the exclusion of much older version which have are in their EOL process.
- Hostile is sexy.

j0k3r

Oh ok so it's an applet I want to make, so I can imitate flash and pretend to be 1337, thanks for your inputs.

Back to my original question, Using Jcreator LE how would I run the applet and see what I have done, is there a button/command I can hit or what do I have to do. All the programming languages I've learned so far have been through the creation of a game, so that is what I'm looking to do for java too.
QuoteAnyone attempting to generate random numbers by deterministic means is, of course, living in a state of sin
John Vo

Banana fanna fo fanna

Load the web page into browser of choice :)

j0k3r

#9
Ok hurray I got it working, now does anybody know where there is just a list of syntax and possibly a brief description of the commands and/or their parameters?

[edit]For the sake of clarity... I'm looking for something along the lines of this...
www.templatecentral.net/treference.JPG
www.templatecentral.net/treference2.JPG
(Big pictures, didn't want to ruin the thread)[/edit]
[edit2]Oh, and no -1'ing me for bad taste in music[/edit2]
QuoteAnyone attempting to generate random numbers by deterministic means is, of course, living in a state of sin
John Vo

hismajesty

Quote from: j0k3r on December 07, 2003, 07:25 AM
[edit2]Oh, and no -1'ing me for bad taste in music[/edit2]

That scared me! I thought you were listening to *gasp* rap.  :P

j0k3r

Quote from: hismajesty on December 07, 2003, 07:49 AM
That scared me! I thought you were listening to *gasp* rap.  :P
I should be asking for -1 if I were to listen to rap.

Ok another question (I won't be back for 5 hours so asking alot now),
I was reading, and trying to remember what I've read before, and kind of lost myself, must java files be compiled and then run each time they are called?
I was also looking at some code, is it ok to create functions/procedures/etc after the main()? Is main() the last part of the program executed?
QuoteAnyone attempting to generate random numbers by deterministic means is, of course, living in a state of sin
John Vo

Kp

Quote from: j0k3r on December 07, 2003, 08:11 AMmust java files be compiled and then run each time they are called?

This question is a bit ambiguous, so I'll be a bit verbose.  The .java file is source, but you don't run that.  The .class file is what's run, and once built it is ready to be loaded into the VM immediately.  You must rebuild your .class file from your .java file when you change the .java, or the .class file will not reflect your changes (i.e. the source changes have no effect on the application until you rebuild the modified .java into its matching .class).  Is that what you wanted to know?

Quote from: j0k3r on December 07, 2003, 08:11 AMI was also looking at some code, is it ok to create functions/procedures/etc after the main()? Is main() the last part of the program executed?

In most languages, and afaik Java is no exception, there's no particular constraint on the ordering of functions within a source file.  main() is the first function of your code that is executed, but its physical position in the source file is irrelevant as long as the name and signature are correct.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

j0k3r

#13
Quote from: Kp on December 07, 2003, 11:28 AM
Quote from: j0k3r on December 07, 2003, 08:11 AMmust java files be compiled and then run each time they are called?

This question is a bit ambiguous, so I'll be a bit verbose.  The .java file is source, but you don't run that.  The .class file is what's run, and once built it is ready to be loaded into the VM immediately.  You must rebuild your .class file from your .java file when you change the .java, or the .class file will not reflect your changes (i.e. the source changes have no effect on the application until you rebuild the modified .java into its matching .class).  Is that what you wanted to know?
Yes, that is what I wanted to know, thanks alot.

Quote from: Kp on December 07, 2003, 11:28 AM
Quote from: j0k3r on December 07, 2003, 08:11 AMI was also looking at some code, is it ok to create functions/procedures/etc after the main()? Is main() the last part of the program executed?

In most languages, and afaik Java is no exception, there's no particular constraint on the ordering of functions within a source file.  main() is the first function of your code that is executed, but its physical position in the source file is irrelevant as long as the name and signature are correct.
I've never been one to be satisfied with just having something work, I always want to know why.

I think I understand, in the first programming language I learned (I think), you have to declare functions and procedures before you can use them (I guess so that the interpreter can use them when they're called), I was wondering how this one works. In java, when the compiler/interpreter encounters a function or procedure, does it look through the code to find the function?
QuoteAnyone attempting to generate random numbers by deterministic means is, of course, living in a state of sin
John Vo

Kp

Quote from: j0k3r on December 07, 2003, 11:53 AM
I think I understand, in the first programming language I learned (I think), you have to declare functions and procedures before you can use them (I guess so that the interpreter can use them when they're called), I was wondering how this one works. In java, when the compiler/interpreter encounters a function or procedure, does it look through the code to find the function?

I haven't looked at the innards of how javac and java.exe work.  However, typically what happens is that the compilation phase will just make note of unseen functions as it goes, then go back and resolve them.  Anything that can't be resolved is a link error.  Then the VM has it easy, since (assuming the class isn't corrupted), all fixups have been taken care of by the compiler.  Beware that I'm extrapolating this based on how I understand C programs are compiled - Java may not do it along these lines.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!