Everywhere we read that to kick start a java program we need a starting point and that is a static main method. In a Java EE application where is that main method present. Is it inbuilt in application server/ container? How it gets triggered and what modifications we can do with that?
Asked
Active
Viewed 2,517 times
4
-
2The main method is defined in the application server. Your application will be handled by the application server. – Luiggi Mendoza Feb 09 '15 at 17:30
-
@Luiggi Mendoza Could you provide more detail on that? – Aalekh Feb 09 '15 at 17:32
-
What exact detail you want/need on that? What's your real concern on this? – Luiggi Mendoza Feb 09 '15 at 17:32
-
@LuiggiMendoza My main concern is that do anyone has access to that main method? In case someone customize it. – Aalekh Feb 09 '15 at 17:34
-
Well, that depends on the implementation of the application server. I guess you cannot, but that goes into the *too broad* category. – Luiggi Mendoza Feb 09 '15 at 17:35
1 Answers
6
With Java EE there is no such thing as main. Depending on your configuration, everything is bound to an URL which will execute the Bean it binds to. An example if you are using JSF would be Faces-config.xml
. If you are using simple servlet then it would be web.xml
.
The Java EE Server will then simply simulate POST
or GET
request.
Another possibility would be to embed Java Applet which would contains a main
, however this is not Java EE.
The program that is running the main
is your server. For example, Tomcat, OC4j, GlassFish, Weblogic, etc.

Mark Rotteveel
- 100,966
- 191
- 140
- 197

Jean-François Savard
- 20,626
- 7
- 49
- 76
-
1You can indeed create common console Java based applications with a `public static void main(String[] args)` that are handled by the application server (I'm not talking about an Applet here). This is not commonly known but it can be done. And **there is** a main method but you should not worry about it. – Luiggi Mendoza Feb 09 '15 at 17:31
-
@LuiggiMendoza I know that, but it would not be considered as `Java EE`. Is this really the reason of the downvote ? – Jean-François Savard Feb 09 '15 at 17:33
-
I would omit the point on Java Applet because it's not Java EE related at all. And on the point about using `public static void main(String[] args)`, here's an example of a basic console application being handled by the application server: https://www.youtube.com/watch?v=qk4qYQG5tvM – Luiggi Mendoza Feb 09 '15 at 17:37
-
@LuiggiMendoza I know that you can handle the `main` however I don't see any good reason to do it as `Java EE` is not build for this. And if you read my answer correctly, you'll notice that I specify that `Applet` is not `Java EE`, just giving in more details. – Jean-François Savard Feb 09 '15 at 17:43
-
Seems like you haven't watched the video I posted in my comment. – Luiggi Mendoza Feb 09 '15 at 17:43
-
-
Then *testing purposes* is a good reason for me. Let's just stop this discussion here. – Luiggi Mendoza Feb 09 '15 at 17:44