Why a single .java file can't have multiple public classes defined in it?

A public class must be saved in a .java file with the same name, why?

Tejaswi.Khijwania wrote:
A public class must be saved in a .java file with the same name, why?This is what the JLS states (7.6 Top Level Type Declarations),
When packages are stored in a file system (7.2.1), the host system may choose to enforce the restriction that it is a compile-time error if a type is not found in a file under a name composed of the type name plus an extension (such as .java or .jav) if either of the following is true:
* The type is referred to by code in other compilation units of the package in which the type is declared.
* The type is declared public (and therefore is potentially accessible from code in other packages).
This restriction implies that there must be at most one such type per compilation unit. This restriction makes it easy for a compiler for the Java programming language or an implementation of the Java virtual machine to find a named class within a package; for example, the source code for a public type wet.sprocket.Toad would be found in a file Toad.java in the directory wet/sprocket, and the corresponding object code would be found in the file Toad.class in the same directory.
As you can see a host system (development system) may enforce this restriction. It doesn't have to.

Similar Messages

  • Can we have multiple database audit specification on a single server audit ?

    Hi,
    We are having a 2 node Sql Clustered instance of SqlServer 2008 R2 Enterprise running
    on windows server 2008 R2. We have about 88 databases in the instance.
    Our servers run on Intel Xeon(R) CPU X5670 @2.94 GHz with 6 cores(12 logical processor).
    The servers are having 12GB of RAM.
    We are planning to introduce database level audit to find if there is any activity on
    some of our databases. These databases are not growing in size and there is a request
    from the application team to ascertain whether the endusers are accessing the database
    over a period of time. In this context I have 2 queries-:
    1)Can we have multiple database audit specification on a single server audit ie can we
    audit multiple databases to find out the user activity on those databases at a time? Or
    should we a separate server audit for each database audit specification?
    2)We plan to have the target of the audit on a file on the same shared volume(lun) where
    the MDF file and LDF files are located(in EMC storage) and in this context what performance
    monitor counters should we watch to ascertain whether there is any performance degradation
    due to introduction of server audit.
    Thanking you in advance
    Binny Mathew.

    As Auditn  is at the SQL Server instance level. You can have multiple audits per SQL Server instance.
    http://msdn.microsoft.com/en-us/library/cc280386.aspx
    Database Audit Specification
    The Database Audit Specification object also belongs to a SQL Server audit. You can create one database audit specification per SQL Server database per audit.
    The database audit specification collects database-level audit actions raised by the Extended Events feature. You can add either audit action groups or audit events to a database audit specification. Audit events are
    the atomic actions that can be audited by the SQL Server engine. Audit action groups are predefined groups of actions. Both are at the SQL Server database scope. These actions are sent to the audit, which records
    them in the target. Do not include server-scoped objects, such as the system views, in a user database audit specification.
    Database-level audit action groups and audit actions are described in the topic SQL Server Audit Action Groups and Actions.
    You can also consider using a Profiler trace file to capture the events.
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Can you have multiple itunes accounts on a single computer?  want to open a separate one for our daughter (but we will manage it).

    just got our daughter a new iTouch, but want to try and keep hers separate from our iPhone stuff.  can you have multiple iTunes accounts on a single computer?

    This is all i know but all you can do is just creat a new one for them both and send all the stuff to the one think u can do that i hope it helps

  • HT2534 Can you have multiple ITunes accounts under a single e-mail address (i.e. separate accounts for my children and myself?)?

    Can you have multiple ITunes accounts assigned to a single e-mail address?  i.e. different Apple ID's for my kids and myself, but all assigned to my e-mail address.

    No. Each account must have uniquie email address.

  • Can you have multiple libraries on a single iPod?

    Can you have multiple libraries on a single iPod?

    Yes.  This explains how >
    Using iPad or iPod with Multiple Computers:  http://support.apple.com/kb/HT1202
    Note:  You cannot load music from multiple computers or iTunes libraries onto iPod shuffle and iPhone like you can with other devices.

  • Can We have multiple SLEDs maintained in a single Batch

    Hi all
    Can we have multiple SLEDs maintained within a single batch. This SLED would be maintained at Quant level. One batch will have multiple quants and would be maintained in separate bins. However in LX27 i should see both the SLED for the same batch.
    Please Help
    Thanks & Regards
    Jajati

    My sources tell me that batch management is not a part of Retail but of logistics and unfortunately I am not able to move your post to a better thread. However, I suggest you please do a search of all forums using "batch management" as your search criteria.You'll see loads of hits. You might find your answer there or a better place to post your question.

  • Can you have multiple contact forms in a single Muse site?

    I have a site created in Muse that needs to use multiple contact forms of a sort.  One is a simple contact form.  Two others are sign up forms. In two of the three forms I have to separate the First and Last names.  Also in those there are multiple Custom fields and Message fields.
    The original simple contact form is working fine and has been.  However, I modified one of the pages by adding a second form, the first of the two sign-up forms.  It looked great in Muse, but when uploaded to the site, all of the fields were gone, leaving only the Labels in a single paragraph.
    Does this mean I can't have multiple contact forms in a single site?  If I actually, can, then what might have caused the problem?  And what could you suggest for me to try to fix it?
    Thank you,
    Laura

    Thank you for the information, but I cannot find anywhere in help where to find the field names (if that is my problem).  I changed all the labels and the corresponding text inside the field (remember, Muse does not give access to code as far as I can tell).  When I preview the page in a browser (using FireFox as default, but also tried with IE), everything looks good.  When I export to html and open the index.html on my computer, everything still looks great.  But when I FTP the page to the website, this is what I get:
    First Name:RequiredRescuer Email:RequiredOrganization (if any):RequiredSubmitting Form...The server encountered an error.Form received.Geographic Areas Covered:RequiredRescuer Cell Phone:RequiredRescuer Home Phone:RequiredRescuer Home Address:
    RequiredRescuer City:RequiredRescuer State:RequiredRescuer Zip code:RequiredRescuer Country:RequiredVeterinarian Name:RequiredVet Address:RequiredVet City & State:RequiredVet Phone:RequiredRequiredServices Offered:RequiredAdditional Info About You:Required Rescuer (available to general public) RequiredVolunteer (available only to Rescuers)RequiredPhoneRequiredEmailRequiredOtherRequiredLast Name:RequiredImage Verification:Required
    How would you prefer to be listed?
    How would you prefer to be contacted?
    However, this is how it looks on the preview:
    So, what is my problem?  And how can I fix it?
    Thank you,
    Laura

  • What are the names ( or a link to them) of Java files I should have? Thanx in advance.

    What are the names (or a link to them) of Java files I should have installed? Thanx in advance.

    This doesn't make sense.  It's more complicated than that.
    OS X will offer to install Java if you need it, unless you've gone in and deleted stuff and made a mess of things.  Did you manually go deleting stuff?

  • Can I have multiple TFS instances use a single SSRS installation

    Can I have multiple TFS instances use a single SSRS installation?
    Thanks

    Hi Kim,
    According to your description, you have multiple TFS instances using one Reporting Services instance. Right?
    For installing TFS, to use a named instance with Team Foundation Server, you must install SQL Server by using a named instance, or move or restore Team Foundation Server data to a named instance, or create a team project collection on a named instance. Please
    refer to the link below:
    Work with SQL Server Named Instances
    Reference:
    Understanding SQL Server and SQL Server Reporting Services
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • If you have two public class in a java file what will be the error ?

    Q:If you have two public class in a java file what will be the error and how will you remove that.?

    Kannan_S wrote:
    I dont want you to be on that list . Here goes my explanation..
    A class is well defined with members and functions
    An abstract class is not defined well as compared to a full fledged class (talking more generically)
    An interface is more abstract.
    I was asking the author who has posted this question to be like a class(very clear)
    and not either as an abstract class or an interface
    Hope i have made it clear..Not in the slightest. This has absolutely no bearing whatsoever on the question asked. Not to mention that classes are classes, and all equal in the eyes of the compiler, be they abstract, concrete or interfaces. It's difficult to see what your point is, to be honest, but I suspect it wouldn't be worth seeing anyway

  • Can i have multiple ActionServlet in a web Application?

    Hi
    Can i have multiple ActionServlet in a web Application?
    if YES then please give me the sample configuration file..
    thanks & Regards
    raghavan

    Hi,
    This forum is related discussions about creator. Please post this to an appropriate forum
    You may post here
    http://forum.java.sun.com/forum.jspa?forumID=33
    MJ

  • How can I have multiple users on iTunes (in order to connect to a shared office iPad)?

    How can I have multiple users on iTunes (in order to connect to a shared office iPad)? Currently each of us has our own iTunes account, so I've made an "all office" Apple ID. However, I can't seem to get two different accounts (my personal and the office) to work on my machine. Even when I login as "the office", my personal library is still showing. Additionally, when I try to setup with a first-time use in iTunes, I get an error that I don't meet the minimum age requirement - no matter what birthdate I enter!

    The library exists regardless of which user is logged in.
    The only way around that is to create different user accounts on the computer.
    There is no way to have 20 unique iTunes users access a shared iTunes under a single login on the computer.

  • HT4436 can I have multiple icloud accounts on one device

    can I have multiple icoud accounts on one device (ipad)?

    Are you sure only primary account can use Find my iPhone?
    I added a secondary account to my daughters iphone and was able to use it for Find my iPhone.
    It warns you that the Find my iphone service will be disabled on the other icloud account.
    I think this is a good change so I can use a single account to track all the devices.
    Looks like only photostream and documents/data are tied to the primary account.

  • Can I have multiple computers accessing one iTunes library simultaneously?

    I've purchased a Lacie Network HD that I'm keeping all of my iTunes on. I've put an alias to the iTunes library from that drive in the music folders of the computers I want to access and update it. That all works well. The only problem is that both computers cannot have iTunes running at the same time. I get an error stating that the library is locked. It would appear that I can't have multiple computers accessing the library at the same time. Is there a work around for this aside from doing network sharing via iTunes? The reason I don't want to do that is that I want both computers to have access to the actual files if I'm using the various iLife apps that use iTunes.

    Scott
    The only problem is that both computers cannot have iTunes running at the same time. I get an error stating that the library is locked. It would appear that I can't have multiple computers accessing the library at the same time
    This is true. It's not a server app.
    The nearest thing would be a library file on each machine pointing to the same set of music files. However, you might have problems if both machines try to access a particulat track at the same time. Also, changes made on one machine would not be reflected in the other. So if you rip a CD on one, the files will also have to be 'imported' to the other.
    Regards
    TD

  • Can we have multiple Podcasts with the same Mac Account?

    Hi all,
    Can we have multiple Podcasts with the same Mac Account?
    For example, I have a single .MAC account and create a website with multiple Podcast pages...or within iWeb I create multiple sites, and each has a podcast.
    Is there a problem?
    Thks
    Leo

    Its not possible for the same development object. Only 1 person can access an object at a time and if mutiple users modify an object new TASKs are created under the same TRANSPORT.
    Only after releasing the tr you can create a new tr on the same object.
    Message was edited by:
            Abhishek Jolly

Maybe you are looking for

  • Recording selected media from previous iDVD

    What is the proper way to copy a selected piece of media from a previous iDVD I made? (Unfortunately I don't have the original files just an iDVD disc.) I want the video w/ accompanying audio but not the template it was created with. I want to rename

  • Publishing Webi Section in Dashboards 4.0

    Hi Guys, Is it possible to publish a Webi report Section into Dashboards 4.0. If not, is there a work around it?

  • Delete XML nodes with E4X

    I trying to delete all the node from a XML that doesn't match some values. <Data>      <Type id="1">           <Details id="1">                <Products id="1">                     <Value>123</Value>                </Products>           </Details>   

  • Get a online number page does not exist!

    This is the 3rd time this is happening to me in about 2 weeks with no success. I go to the online number page and everything works fine. I can view my existing online numbers and so on. However when I click on the link get an online number because I

  • HT1918 how do i delete an email from my account

    How do I delete my daughter's email from my account so that she can create her own apple id