Valhalla Legends Forums Archive | Java Programming | Creating Programs in JCreator LE

AuthorMessageTime
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?
December 6, 2003, 3:05 PM
St0rm.iD
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.
December 6, 2003, 6:06 PM
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.
December 6, 2003, 6:21 PM
St0rm.iD
Yes, you can. Write a loop :)
December 6, 2003, 6:24 PM
j0k3r
[quote author=St0rm.iD link=board=34;threadid=4106;start=0#msg33970 date=1070735056]
Yes, you can. Write a loop :)
[/quote]
So it can do either? Alright I know how those kind of languages work, but why wouldn't I want to make an application?
December 6, 2003, 9:39 PM
St0rm.iD
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.
December 7, 2003, 1:10 AM
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.
December 7, 2003, 1:22 AM
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.
December 7, 2003, 4:04 AM
St0rm.iD
Load the web page into browser of choice :)
December 7, 2003, 6:02 AM
j0k3r
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]
December 7, 2003, 1:25 PM
hismajesty
[quote author=j0k3r link=board=34;threadid=4106;start=0#msg34105 date=1070803552]
[edit2]Oh, and no -1'ing me for bad taste in music[/edit2]
[/quote]

That scared me! I thought you were listening to *gasp* rap. :P
December 7, 2003, 1:49 PM
j0k3r
[quote author=hismajesty link=board=34;threadid=4106;start=0#msg34106 date=1070804942]
That scared me! I thought you were listening to *gasp* rap. :P
[/quote]
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?
December 7, 2003, 2:11 PM
Kp
[quote author=j0k3r link=board=34;threadid=4106;start=0#msg34107 date=1070806289]must java files be compiled and then run each time they are called?[/quote]

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 author=j0k3r link=board=34;threadid=4106;start=0#msg34107 date=1070806289]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?[/quote]

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.
December 7, 2003, 5:28 PM
j0k3r
[quote author=Kp link=board=34;threadid=4106;start=0#msg34133 date=1070818084]
[quote author=j0k3r link=board=34;threadid=4106;start=0#msg34107 date=1070806289]must java files be compiled and then run each time they are called?[/quote]

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]
Yes, that is what I wanted to know, thanks alot.

[quote author=Kp link=board=34;threadid=4106;start=0#msg34133 date=1070818084]
[quote author=j0k3r link=board=34;threadid=4106;start=0#msg34107 date=1070806289]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?[/quote]

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.
[/quote]
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?
December 7, 2003, 5:53 PM
Kp
[quote author=j0k3r link=board=34;threadid=4106;start=0#msg34136 date=1070819617]
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?[/quote]

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.
December 7, 2003, 7:16 PM

Search