Why does main() need to be static?

Hi all,
I am trying to understand why
public static void main(String[] args)needs to be static?
I know that it needs to be available before the JVM creates an instance of the class containing the main method, but why is this the case? Is there some reason why the JVM cannot create an instance at that point?

Hi all,
i shall try to explai you this puzzle.
for a class as follows:
========================================
class abc{
abc(){ ..... }
public static void main(String[] a){
========================================
when i compile it it runs perfectly but if i remove the static modifier from main it throws an exception.
that is beacuse jvm lies outside the bounds of the class(opr default pacgage) and so if i want to call any method from there (or basically from outside the package) it has to be declared public.There should be no arguments here as this is the very idea of access protection.
Now simce main returns nothing so it has to be void.The String array argument is place holders for command line arguments (thats for compatibility for users comming from c++)
Now static why????
in java when we call a classes constructor or when a class is instantiated all the prop[erties of that class are created with values or behaviour specific to that object and in general defined by the class.This you may agree with i suppose.Now if i need to call a method print of class abc then i need to first make an object of class abc (lets say ABC ) and call print as ABC.print("ddd"). This call shall execute the logic specifically defined in the behaviour of the particulay object ABC of class abc and this not necessarily  can be same as the default call behaviour.
But suppose i have a method that always returns the sum of two integers no matter what object it resides in, I would make it statis because this method would not be a copy in all the objects created rather one master copy that all the objects would use.So now ABC.add() would return same as BCD.add(). But the thing is what do i need to do when i am calling this method for somewhere outside the package.(e/g jvm calling main)Since i don't have the object i cannot call the method.
using static i can have an entry point into the jvm as static methods are executed using classname.methodname().
Once the entry poinjt is loaded(main here) i can call the constructor ,make the object and proceed.
hope this helps,
waliv.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • Why does Bridge Need Illustrator to Save as PDF compatible file?

    1. Why does Bridge need Illustrator files to be saved as PDF files? "PDF Compatible File" ticked in the save menu.
    2. Why does saving with this info take so long, even on decent fast modern systems?
    3. Why does Bridge not consistently render the Illustrator files in FULL RESOLUTIONS, seemingly shooting for half resolution much of the time, and simply stopping at that?
    4. Why does "clicking" on the preview inside Bridge bring up the full resolution?
    5. How do I shortcut this process so that every file is previewed in Full RESOLUTION, instantly?
    What is the point of Bridge?  What's its reason for existence?
    First time user of Bridge.

    Since someone is bound to say that this should be asked in the Bridge section... it already is.  And has been referenced back over here.
    You can find it here:
    http://forums.adobe.com/message/5655632#5655632
    Answer wherever you see fit, if you're up to the task of dealing with someone attempting to have a broader view, perhaps also suffering from somewhat objective analysis that sometimes contains direct criticism of the way Adobe does things.

  • HT201250 If time machine backups hourly.  Why does it need to backup daily, weekly and monthly

    If time machine backups hourly.  Then why does it need to backup daily, seekly, and monthly?

    It doesn't.
    What it does is discard intermediate backups at the end of 24 hrs and keep just three spaced backups from the previous day.
    At the end of the next day, that day's will be reduced to 3, and the previous 3 trimmed to one; the last backup of that day.
    Daily backups are kept for a month, then trimmed to the last backup of the week.
    The weekly backups are kept until the disc runs out of space and TM starts deleting the oldest ones.

  • Why does m4v need to be converted again

    Hi. I converted a dvd movie I bought into the ipod format .m4v using another converting software program I have. I then imported it into the videos section of my itunes. It would not load into my ipod unless i convertd it again using the itunes conver for ipod option. Why does this need to be converted again for ipod if its already in a .m4v and is there any way i can fix this so when im originally converting my movie with my converting software I can eliminate this last step in itunes. It takes up to 5 hours to convert in itunes. thanks

    I should also add that I am using a AVS video converter which has an IPod 5.5 converting option that makes my movies Highest available quality H.264, 30fps 640x480
    There are more Ipod options availble but im using the Highest quality available one. Maybe I should be using one of these:
    ipod 5x- NTFS Standard quality H.264 29.97fps, 320X240
    ipod 5x- PAL standard quality H.264 24fps, 320X240
    ipod 5x- low quality H264., 20fps, 320X240
    ipod 5x - Best quality (MPEG4, 24fps, 320X240)
    ipod 5x- economy quality (MPEG4, 20fps, 176X144)
    ipod 5x- for tv output (MPEG4, 24fps, 512X384)

  • HT1766 If in App Store and things are free or already downloaded why does it need my bank info

    If in App Store and things are free or already downloaded why does it need my bank info

    ITunes/App Store needs verification.
    Put in your valid credit card details associated with your Apple ID.
    You won't be charged if it's free.

  • When I import a Quick Time movie into the timeline using Final Cut Express, why does it need rendering?

    when I import a Quick Time movie into the timeline using Final Cut Express, why does it need rendering?

    Because your clip properties do not match your sequence settings.
    It will help a lot if you provide details ...
    FCE Easy Setup
    Sequence settings (vid rate, frame size, compressor)
    Source of your clips (camcorder make/model, etc)
    Clip properties (vid rate, frame size, compressor)

  • I cannot install apps that are upgraded to ios4.. im using iphone 2g 3.1.3 this makes me sad.. why does apple need to updates many apps when we cannot update an iphone 2g anymore..

    i cannot install apps that are upgraded to ios4. im using iphone 2g 3.1.3 this makes me sad.. why does apple need to updates many apps when we cannot update an iphone 2g anymore..

    I am having the exact same problem with trying to sync my iPad with my computer. To make a long story short, I had to reinstall Windows for my computer and therefore had to reinstall itunes.
    I have done back ups in the past for my ipod touch and other ipods with no problems, but unfortunately I have never been able to back up my iPad. During a sync, the iPad would always disconnect from my computer and it would never finish. it would say the connection was lost, but nothing is wrong with the connection.
    So now I have over 100 apps and thousands of pictures that I am afraid will be deleted if I run the sync in itunes. I have tried to transfer purchases and it goes through the list of apps, but nothing is ever transferred.
    Any help would be appreciated. I am not interested in jailbreaking my iPad to solve this problem. There should be a fix for this and I want to upgrade to ios 4.3 as the original poster. Please help

  • Why does EJB needs two interface???

    Hi All,
    This has been asked by many ppl and many of you might be having
    the correct answer for it. Please tell me....
    Why does EJB needs two interface (Home and Remote Interface)?. Why not one?
    Thanx to all...
    Regards
    GoodieGuy

    Hi Goodie ,
    Its good question and its a very valid one , one has to have doubt
    why two , why not one ..
    Here the answer goes ..
    First of all you need to understand that its a distributed computing technique ie I mean lot of people will be accessing the bean at the same time , right ? OK , you cann't access the bean directly.
    and lastly the stateless and entity beans do instance pooling.
    The very purpose of having two interfaces is
    1) To differnentiate the bussiness logic and life cycle methods .
    2) The home interface inititates life cycle methods like creation , destruction etc .
    3) There are lot of beans in the container , and through home you are
    creating the instance or accessing one of them .
    4) Once you have home object using it we get the remote object ie the instance of the bean that you want to access if stateless any bean can be called , if statefull depending upon the parameter in create method that respective bean is created and invoked .
    In ejb 1.0 and 1.1 even though the bean and the client are in same jvm its assumed that they are remote and in 2.0 Ver we have local this is to avoid network traffic .
    Hope you have got the answer , but if u still need clarification
    read EBRoman book first and second chapters thoroughly and then proceed
    a head.
    Bye
    Mahesh L.
    ============

  • Does main need to be public?

    I'm a little confused as to why the following code works...
    public class FirstClass {
        //public static void main( String[] args ) {
        //    System.out.println("Public main()");
        private static void main( String[] args ) {
            System.out.println("Private main()");
    }This is being run on 1.2.2. I was under the impression that main needed to be public for the system to call it. But when I run this it prints 'Private main()' to screen. This is also true if I make main protected.
    Any ideas as to why this still works?
    Thanks
    Ade

    It seems that the main signature does matter, but the
    access modifier doesn't.Both the JLS and the JVM specs require that the main method to be public (note however that you are allowed to have a private, static, void method that takes a single String-array argument, but it should not be considered an application entry-point).
    This was a bug introduced into Sun's VMs with early 1.2 releases; Originally there was no intention to fix it, but eventually they decided to do so, and it was fixed for 1.4.
    If you do not declare your main methods public, static and void, you will find that your applications stop working one day when you switch Java versions, or when you roll the code out to clients using a different version to that which you developed and tested the apps on.

  • Use Mobile Data For: Settings - Why does Settings need a cellular data connection?

    iPhone 5 iOS 8.1
    Settings > Mobile > Use Mobile Data For: Settings
    Just curious, why does the iPhone need this turned on? Why does the settings app need a cellular mobile data connection?
    If you turn it off, you're pestered to turn it on every time you go into settings?

    Because, that's the way Siri works...it needs an Internet connection...requests are sent to Apple's servers. No Internet, no Siri.

  • Why does data need to be turned on for group texting?

    Why does single person text msg only need cell service, but group texting requires data turned on?

    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • Why does WebUtil needs AS configurations?

    If we have to only attache the WebUtil.PLL and sub-class the webutil.olb to the form and place the frmwebutil.jar in the \%Oracle Dev Home%\forms\java then why do we need such a complicated set-up in the app server (like signing with JACOB which I really don't understand)? Do we have to install any Java components in the DB also?
    Can anybody explain to me what happens when a 10g Release 2 Form tries to read an Excel sheet from the client machine? In simple steps can you plese explan what WebUtil components are called and where those components are (client/app server/DB machine)? How does the application server come into play when a Form reads from an Excel sheet in the client machine because the Excel sheet is in the client machine and NOT in the app. server or DB machine?
    Please pardon my ignorence in this. I tried reading the documentation (PDFs and web-pages) but I could not figure how it works.
    Edited by: user12240205 on Apr 29, 2011 6:06 AM

    then why do we need such a complicated set-up in the app server (like signing with JACOB which I really don't understand)?JACOB stands for JAva-COm Bridge. This is the mechanism by which Oracle Forms is able to interact with the Client workstation and call Windows COM Automation components. Without the JACOB library (.jar) WebUtil would not work. You have to sign the jacob.jar because your application is deployed over the web.
    Do we have to install any Java components in the DB also?No - you only need the WebUtil database package.
    Can anybody explain to me what happens when a 10g Release 2 Form tries to read an Excel sheet from the client machine?Forms uses the Webutil Client_OLE2 package to communicate with Excel using Windows COM methods. As I mentioned above, without the JACOB library, WebUtil would not be able to communicate with Excel using COM.
    In simple steps can you plese explan what WebUtil components are called and where those components are (client/app server/DB machine)?Rather than explain each step, there are numerous demo's on the internet and in Oracle's Forms Demos that demonstrate how to use WebUtil. It is also a very common topic in the Forums. I recommend you look at WebUtil - A Simplified guide to understanding WebUtil. Also take a look at Forms: How to Read an Excel file into a Form for an example of how to interact with Excel.
    How does the application server come into play when a Form reads from an Excel sheet in the client machine because the Excel sheet is in the client machine and NOT in the app. server or DB machine?{qoute}The Application Server (AS) is simply the transport mechanism to deliver the JACOB Java Library to the Client. When a Forms interacts with Excel - everything occurs on the client. Depending on what you are attempting to do, the AS may never be involved with a WebUtil transaction on the client. Now, if you need to upload a file or store a client image in the database then the AS and the Database server would become involved.
    Hope this helps,
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • Cineform - what is it ? why does one need it ? what am I missing ?

    Hello,
    I am very puzzled with what Cineform is. I have been to their website, but they don't do a very good job at describing what Cineform is, or what it does, and why somebody would need it.
    Could somebody who has a few moments, explain what Cineform is, and what it does, and how it make Premiere better ?
    I just don't understand it at all, and I'm afraid I may be missing out on something important.
    Thank you,
    Dave.

    Temporal compression is a way of making files smaller. Rather than storing all the data for every frame, you store only the data for the first frame, and then you store only the changes from frame 1 to frame 2, and then the changes between frame 2 and frame 3, etc. For any given second of video, 30 frames worth, only two are stored in full. All the rest only store the changes.
    For news type programs, also called talking head shots, very little changes between frames, so this is a very good way to save space.
    During a high action scene, a lot will change between frames, and it becomes more difficult to store the data using this method. This is why artifacts are created, errors during the encoding that do not allow a correct display of the video. This is also why a lot of professionals often prefer formats that do not create such artifacts in the source footage. Temporal compression is a good way of shrinking video for final display, but often causes issues when you use it to shoot the original scene.
    It takes much processing power to restore those change related frames for display. Cineform takes the load off the processor by doing the work ahead of time. It converts the files before you import them, thus restoring the "change frames" to "full frames", making it very easy for Premiere to display them, and edit them.

  • Why does compressor need to be connected to internet to work?

    I am using an 8 core macpro with 10.5.2 installed and final cut pro 6.0.3
    when I put a job in compressor and try to submit the job, compressor says it has an unknown time remaining , and nothing ever gets done. That is because I have blocked the out going connection to a couple of ports that my firewall was telling me compressor tried to connect to the internet when I submitted this job.
    If I do NOT allow compressor to connect to the internet, I can NOT use it.
    After I allow compressor to connect to these weird ports, only then can compressor work.
    DId compressor get infected with a virus or something? Why do I need an internet connection to use compressor?

    its since I updated to final cut 6.0.3
    This problem is not unique to just me, a search for "compressor unknown time remaining" in google shows alot of people with this issue
    http://www.google.com/search?client=safari&rls=en-us&q=compressorunknown+timeremaining&ie=UTF-8&oe=UTF-8
    sadly, I have yet to find a solution other then it working on 6.0 and 6.02
    please do not say its user error when I have tried all the so called workarounds and none have work.
    it works when I let it connected to the ports it connects to, if I do not let it connect to the ports, it doesnt work
    Message was edited by: piff aroni

  • Why does imovie need to keep the original file after I have edited?

    I record basketball games with my ipad and I keep the footage but cut the video so I can make highlights for the season. Thing is, these original videos are usually close to 10GB each and over an hour long.
    I might have 5 minutes of highlights when Im done.
    So to save space in my Imovie projects, I kept the clips i want and deleted the videos. When I came back to add more video to my season project, it said missing file.
    Does it need to save the entire original media after I cut the video? I dont want to keep every game on my computer, I just want to keep what I cut and throw the rest out. But Imovie is asking for the original file.
    Any solutions for this, or do I need to upgrade to a more professional editor?

    Hi
    You are using a - Non Destructing Video Editing program.
    Meaning that Your movie in making ==> Project - DO NOT contain any movie or material at all - BUT only a text document pointing to where material is stored e.g. folder iMovie Event's, other hard disks, DVDs, CDs or USB-memories.
    And if any of these storage's are moved or disconnected - iMovie get's lost and can not View Your Project.
    iMovie - do not have any "Media Managing Function" as FinalCut Pro (as it can reconnect moved material and create a complete contaning folder)
    Even when You Shared Your movie - there still will be links back to material - to make it possibly to further editing's, and Sharing in other resolutions.
    This is the cost of working this way. So I use an external hard disk for storage
    - MUST BE - Mac OS Extended (hfs) formatted - UNIX/DOS/FAT32/Mac OS Exchange will not work for VIDEO
    - Moving Video Event's - MUST BE DONE WITHIN iMovie Application - ELSE connections will be broken - meaning HARD to IMPOSSIBLY to mend later. Be aware !
    All other material I store in Folders named as movie project + date - all from start on the external Drive.
    Yours Bengt W

Maybe you are looking for