Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Java (http://www.programmingforums.org/forum17.html)
-   -   Java on a large scale... (http://www.programmingforums.org/showthread.php?t=15558)

IisNoob Apr 6th, 2008 12:57 AM

Java on a large scale...
 
I always hear people talking about Java web uses...I'm a highschool student, and I'm in a Java class and I'm not horrible at it but I could be better. Anyways I don't really understand stand alone Java because, when I compile (I use blueJ) its not like C++ where I see an exe and I can run that directly...I can only run this code I keep writing , through this editor... and since obviously not every one in the world has blue jay on there computers, they could never utilize the code I write. If someone could just explain stand alone java as versus web java that would be awesome :)

Jabo Apr 6th, 2008 1:31 AM

Re: Java on a large scale...
 
for a Java program to run alone, within the program class, it should have a main function or method just like in C++. To compile the program, you need to go to command prompt, browse to the directory where your class file is, and enter "javac Class.java" at the command prompt; whereas Class.java is the name of your class file. Once it compiles without error, you can run the program with "java Class.class" at the command prompt.
More info

Dameon Apr 6th, 2008 8:37 PM

Re: Java on a large scale...
 
Your IDE is just a pretty interface to stuff going on behind the scenes.

You enter code. The code gets compiled in to some number of 'class' files. Sometimes, these class files are wrapped neatly in to a 'jar' or 'war' package - just an archive of classes, possibly other stuff too. Your IDE may have a very convenient 'run' button - this translates to compiling the code and then running it. End users do not need your IDE. You simply need to distribute the resulting jar/class/etc. There is an output directory which has these files in it. I have never used blue jay before, but I recall that it is some kind of gimped learning tool. Most any real tool, however, makes it very convenient to wrap your project in to an executable jar. This is exactly the same as a normal jar, but with the additional requirement that one of the class files is the startup class and that class file contains a suitable 'man' function. In most configurations, an executable jar can be run by double clicking.

'Web' java works the same way as standalone java. The difference is how things are started and what you then do.
If you have written a java applet before, recall how they are structured. There is an 'applet' base class which defines certain methods which you may want to override, such as repainting. There is no need for a 'main' function, certainly not a static main function. Rather than calling a 'static' (not associated with an object) method as main is, the program hosting the applet will create an instance of your specialized applet class. It's just "an applet." The program knows that it contains "applet" methods. It can be treated like any other object - it just happened to have been loaded on demand.
"Servlets" (think 'server') operate the same way. There is some particular class that the 'servlet container' expects to deal with. The container will load your specialized servlets, which will respond to web requests just as your applet may respond to drawing events.

mrynit Apr 7th, 2008 5:37 AM

Re: Java on a large scale...
 
you alwasy have to have a JRE to beable to run java, or the hardware to do it.

IisNoob Apr 10th, 2008 10:05 PM

Re: Java on a large scale...
 
Ty all of the responses have helped me see the real use for java, and I have stopped using Blue J and started using netbeans.


All times are GMT -5. The time now is 4:03 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC