Structure of an Application/Applet

Please tell me if this is correct, or if it isn't, what needs to be changed
First you import whatever classes you have to import
Next you create objects of classes, and you call the methods that need to be called
then comes the main method
now here is where you use everything. You use the objects you created, and you use the methods that you called
End program
Is there anything wrong, and is there anything else that should be put in there that might help me in my understanding of how a program works?
I'm in the dark about an applet, because there is no main method in an applet I believe

not quite correct!
here's the right one:
1. you write classes that define some variables and methods and which
have a constuctor(if you don't define a constructor an empty constructor will be added by the compiler)
2.you write a test class
this class must contain a main() method (in applications).
within the main method you create new instances (objects)
of the classes you have written.
example:
public static void main(String[] args)
Myclass myownclass = new Myclass();
myownclass.myownmethod();//calling methods on the new object
}

Similar Messages

  • File structure in large applications

    Hello,
    I have a fairly large application, totaling around ~150,000 lines of code.
    Unfortunately, when I first began building this application, my understanding of file structure and various architectural patterns was quite limited, and the code could easily be labeled as "spaghetti code."
    Since then, I have begun migrating everything over into an MVC structure, but was not entirely sure how to proceed.
    I have one primary file, let's say Application.as that is essentially the main actionscript class, and I am using 'include "com/controller/hello.as"' instead of importing classes because I did not want to clutter up my code by using classes all over the place and having to instantiate them.
    Would creating classes instead of having flat actionscript files be a better way to proceed?
    How do you structure your large applications?
    Are there any resources out there, articles, books, etc., that discuss enterprise level architectural patterns in Flex?
    Thanks!

    Flex is an Object Oriented environment and so NOT using classes and objects will generally lead to the architectural anti-pattern (read Bad) sometimes refered to as the Big Ball Of Mud (aka spaghetti code).
    Just using classes and objects isn't always enough though. If a class is larger than 500 lines of code, it is very probably too big and doing too many things - try and split it up into smaller classes that each do exactly one thing and do it well. If a function is longer than one screen on your display, it is too big and should be broken down into smaller functions.
    One good indicator as to whether or not you have a good class is to use a unit testing framework (http://flexunit.org/) and write tests for the class. If it's hard to test it then it's probably still too complicated.
    How the classes are organized into packages is a less interesting, though if a package has more than 30 classes then there's a good chance that it's too big and you should try and divide it up.

  • Tree structure of portal application in NWDS

    Hi all,
    Im new to portal applications and I did not under stand the tree structure that appears after we start portal application in ep perspective in NWDS. Especially the PORTAL-INF and src.code in the tree structure .If any body has any relevant information or document about it please send me.

    portal applications are same as the Web applications developed in Java, JSP ....
    PORTAL-INF is same as the WEB-INF in normal web application structure.
    in Web application we create .war file whereas here we create as .par file.
    in web application we have web.xml inside WEB-INF folder where as here we have portalapp.xml.
    src.core and src.api is used as the source code folder.
    You can check this in "Java Build path" if u go to the project properties.
    Hope this give u a small idea on portal files structure.
    cheers.
    Chinmaya
    Reward points for hellpful answers.

  • How to structure a JSF application (EAR/WAR/JAR)

    Hi All,
    How do you recommend I should structure a JSF application in terms of EARs, WARs and JARs?
    Let me set the context for you: I have a fairly large project which consists of a number of sub components. Each of these sub components are JSF applications in the sense that they have JSF pages connected to each other. So, for instance, I have a company management sub component and a product management subcomponent. Most of these sub components share some Java libraries and/or entities.
    Because of this I decided to have each sub component contained in its own WAR, with no universal libraries in its lib folder, and to then add these WARs to an EAR with all the library JARs in the EAR's lib folder, as so:
    EAR
       |_ component1.WAR
       |_ component2.WAR
       |_ lib
             |_ sharedlib1.JAR
             |_ sharedlib2.JARUnfortunately I'm having more problems than I hoped I would with JSF with this setup. An alternative I have is to create one gigantic WAR which contains all the library archives and then to only deploy this WAR. Although this would probably work, it destroys the nice seperation I had between sub components, where I could for instance just remove the one WAR from the EAR if it was giving problems. That structure would look something like this:
    WAR
       |_ <WebContent>
       |_ WEB-INF
                 |_ classes
                           |_ <JSF classes>
                 |_ lib
                        |_ sharedlib1.JAR
                        |_ sharedlib2.JARFinally, I have a third option where I add all the libraries required by a WAR to its lib folder and I have no shared libraries in the EAR's lib folder. The disadvantages are of course that the EAR will be huge as JARs get duplicated unnecessarily, and I'm not sure that this won't cause conflicts. The structure would look like this:
    EAR
       |_ component1.WAR
                        |_ WEB-INF
                                  |_ lib
                                        |_ sharedlib1.JAR
                                        |_ sharedlib2.JAR
       |_ component2.WAR
                        |_ WEB-INF
                                  |_ lib
                                        |_ sharedlib1.JAR
                                        |_ sharedlib2.JARI believe the first way to be the best, but I'm struggling getting JSF to work like I expect (see [http://forum.java.sun.com/thread.jspa?threadID=5288069|http://forum.java.sun.com/thread.jspa?threadID=5288069] ). What are your suggestions?
    Thank you,
    Ristretto

    Dear hiwa,
    thank you very much for your response. I have had a look into the book and found out that it provides indeed half of the solution i need. Now I can generate a JSF response to my non-JSF request which has been issued by the main application.
    Unfortunately this is only the first half of the solution, because the JSF framework of the child application will still render URIs into HTML-forms (e.g. for the <f:view>) that point to the faces servlet and not to the non-JSF servlet of the main application.
    I'll try to solve this problem by providing my own ViewHandler that provides other URIs. But I still don't know how to encode the view ID into the generated HTML-form as a hidden field.
    After all, I am really surprised at how difficult it is to integrate the JSF framework into a non-JSF application. I don't think this is a very uncommon scenario. In my case, we integrate into an existing large application of our customer in order to extend his application with our product. I would expect this to work out of the box with JSF (sigh).
    I will post my progress in this matter if I found some interesting solution.
    Bye, Marcus

  • Directory Structure for multiple applications at one host

    Can I have multiple (more than one) WEB-INF directory structures in the public_html directory for different web applications? If I do this, how do setup the url-pattern in the Servlet Mapping tag in the web.xml file? How do I setup the URL that calls the servlet from the HTML that has been send to the user�s browser?

    If I understand your question, you want multiple contexts. All App Servers/Web Servers allow you to setup multiple contexts. Normally if your root context is in /home/myhome/app_server/
    then you would setup multiple contexts by creating a folder for each context:
    /home/myhome/app_server/context1/
    /home/myhome/app_server/context2/
    Each would have their own full application/website. And the way to reference these would be as such:
    if the domain, www.mydomain.com, is mapped to /home/myhome/app_server/
    www.mydomain.com/context1/
    www.mydomain.com/context2/
    I think that is what you were asking. Hope it helps

  • Help with structure of scheduling application.

    I am working on a web scheduling application, very similar to how Microsoft Outlook works.
    We need to be able to set recurrence on various tasks and appointments.
    What we are struggling with, is how exactly to structure the data. Does anyone know how this is usually done?
    At first, we were just going to create individual entries into the database for each recurrence. But we quickly figure out that a task that runs every hour for 10 years amounts to over 87,000 entries. This does not scale well at all.
    Any suggestions would be appreciated.
    Thanks!

    It really depends on what information you need.
    If, for example, you needed to produce a December, 2004 calendar that showed what tasks were going to be executed at what time on what days, then there are two basic ways to approach that:
    1. When you create a task, figure out all of the future times when it will be executed and store those in a database. That has the problem that you already identified, plus others (such as if you want to change a task from running every Monday at 8 am to running every Tuesday at 8 am, you've got a lot of database work to do).
    2. You need to be able to ask a task about its future execution times in a given range. So your task object would just have recurrence information, and it would have a method that takes a start and end date and returns a list of times when the task is scheduled to run.
    But if you don't need that, you just need to know the next time that each task is scheduled to run, then you seem to have a solution to that already.
    The other decision you need to make is whether a task is mutable or not. For example, if I set up a task to run every Monday at 8 am, can I change that to run every Tuesday at 8 am? Or do I need to create a new task to do that, and delete the old one? And if I can change it, what happens to the job that's already scheduled for next Monday? Does that stay there, and all subsequent jobs run on Tuesdays, or does it get changed to run on next Tuesday too?

  • What is the directory structure of EJB applications?

    I am new to EJB program. I know that after the development is done, we package the EJB components into .jar file, and package the Web components (HTML/JSP/Servlets/JavaBeans) into .war file, and then together we package .jar file and .war file into a single .ear file. Then we just deploy the .ear file into WebLogic's application directory.
    But, before the deployment, I mean during the development, what kind of directory structure is good for us to develop our EJB, HTML, JSP, Servlets, and JavaBean components?
    Previously, when I was doing JSP/Servlets applications, my directoy structure is:
    webapps\
    --------myapplication\
    -----------------------*.html
    -----------------------images\
    ------------------------------*.jpeg, *.gif
    -----------------------jsp\
    ------------------------------*.jsp
    -----------------------WEB-INF\
    ------------------------------web.xml
    ------------------------------classes\
    -------------------------------------Java Servlets located here
    -------------------------------------beans\
    -------------------------------------------JavaBeans are located here
    Now, I am doing EJB applications, what should be the directory structure?
    Thank you very much for your help!
    Jingzhi

    I have been involved in a few enterprise applications but have not been happy with the packaging structures used and am starting a new one now and am looking for other examples.
    this is what I've used before.
    web/
    classes/
    client/
    server/
    but if a class was used in the client and server it was put under the server/ package. I feel that more separation is needed.

  • Run java3d applications / applets without having to install java3D

    hi
    is it possible to run a application or applet which uses
    java3d on a computer that has not installed java3D? could
    this be done by adding the required jars to the
    application? i tried this and have added the java3d jars
    to my applet jar, but when i start this applet from a
    computer whithout java3d i get the error "no J3D in
    java.library.path".
    what can i do?

    I think, applets can't directly execute dll files coming from a remote computer. If i understand you correctly, then you need a solution especially for applets. This is imho an unsolved "problem". Please take a look here: http://forum.java.sun.com/thread.jsp?forum=21&thread=339185&tstart=30&trange=15
    Regards

  • Structure input in application service

    Hello,
    I have created an application service that encapsulates an RFC (BAPI). As long I am using simple types as input parameters in operation and structure in output, everything works fine. But if I'm using structure as input and output parameter, I can't use these operation (after deployment to J2EE).
    Can anybody tell me, what the problem is and how I can fix it?
    Thank's in advance.
    Stefan

    Hi, Stefan.
    Yes, if input parameters only have simple types, we are happy
    Anyway, did you check your new service via Web Service Navigator
    tool of J2EE? If so, you can get right SOAP message, and please
    compare that with your program's SOAP message.
    Usually, you have to code something to create complex types tags
    in your program. For example, the following is SOAP request message
    example for BAPI Return(via perl SOAP::Lite module). Even though
    BAPI return value is not needed in input parameters, you have to
    create tags for meeting the complex types.
    <RETURN>
      <item>
      <TYPE xsi:type="xsd:string"/>
      <ID xsi:type="xsd:string"/>
      <NUMBER xsi:type="xsd:string"/>
      <MESSAGE xsi:type="xsd:string"/>
      <LOG_NO xsi:type="xsd:string"/>
      <LOG_MSG_NO xsi:type="xsd:string"/>
      <MESSAGE_V1 xsi:type="xsd:string"/>
      <MESSAGE_V2 xsi:type="xsd:string"/>
      <MESSAGE_V3 xsi:type="xsd:string"/>
      <MESSAGE_V4 xsi:type="xsd:string"/>
      <PARAMETER xsi:type="xsd:string"/>
      <ROW xsi:type="xsd:string"/>
      <FIELD xsi:type="xsd:string"/>
      <SYSTEM xsi:type="xsd:string"/>
    </item>
    </RETURN>
    Good Luck.
    Sejoon

  • For standalone java applications Applet is better or Frame is better?

    Hi Every body,
    Iam new to java standalone application developement.As per my knowledge both Applet aswell as Frame concept can be used to develop java
    standalone applications, if Iam right. My application need menus, drop down menus and it also need to connect to backend database.So which is better?
    So please some body guide me.
    Thanks in Advance
    Basavaraj M

    A JFrame not a frame will be most apropriate because that just what it supposed to be used for but u can consider a JApplet if u want to incorporate it into a web application.
    Sq2000

  • JAVA Combining Applications & Applets

    I'm a student working with GA's and I'm wondering if it's possible to do a couple things:
    1) Is it possible to tweak JDK's optimization settings to run code faster with less safety? - I need speed!!
    2) Say I have data within a standard APPLICATION (class blahblah java static void main (strings[] args) etc.) and I want to pass that data into an APPLET or some system that can graph the data of the program as it is generated? Is this possible? Is their a tutorial or some simple (by simple I mean < 20 lines) code I could learn from please?
    Thanks...

    1. No. You can't increase speed by altering safety. There's a large amount of performance information in this site - both in Sun documents and these forums, do some searching using the advanced search link at the upper right.
    Here's an online book on performance: http://java.sun.com/docs/books/performance/
    2. Just code the whole thing as an application. Applet isn't needed.
    Here's a tutorial on Java 2D: http://java.sun.com/docs/books/tutorial/2d/index.html

  • Directory structure of JMS application

    either we must follow any directory structure just like servlets and ejb as web-inf and meta-inf in JMS.

    No real need - just use the JMS client directly in any JVM.
    If you are using MDBs then yes you need to use an EAR just like EJBs - but alternatively just use spring.xml...
    http://jencks.org/Message+Driven+POJOs
    James
    http://logicblaze.com/
    Open Source SOA

  • How to Hide HTML code of web application (applet)?

    hi
    On web, while running application, if user open View\Source from browser, he can see all HTML code (base_jini.html). The problem is that we can't afford to show source code to client, because it has DB connection inf (username/password) as well. How this html code can be hide from client machine?
    I think, i convey my prblom. If not, please run any web application and try to see source code from browser view menu, U will see that all configuration details are visible including db password. I suppose there should be some way to hide these details to client.
    Please help in this regard, i will be very thankful
    regards
    Asif

    Forms Listener Servlet is just another way of setting up forms on the web. The main difference is instead of the client and the Forms runtime talking directly, they do so via the webserver. This means thay you only need to have one port opened in your firewalls (e.g. 80) instead of two (80 and 9000)
    Please read the paper I indicated and this will hopefully explain it all.
    As to the suggestion of using the LOGON built int - this would be a solution but you will have to consider if this is acceptable if you have more that one user since the person running the application would have to identify themselves in some way.
    The other option is do not add the username and password in teh HTML and the default logon dialog will appear.
    Regards
    Grant Ronald
    Forms Product Management

  • Guidelines for deciding directory structure for Swing Application

    Hi,
    We are developing a Swing Application for our organization. We want to organize the code and resources/icons/properties files in correct manner.
    We have guidelines for arranging the code for web application. Is there any such guidelines available for desktop application as well? What is the preferred location for keeping the icons and properties files?
    Regards,
    Manu

    Thanks Maran.
    I have already checked many installation guides before posting here. All of them mention about creating folders like /admin or /oradata on various mount points but none of the naming conventions really indicate whether it is a 8i database or a 10g database.
    This is required when you are having multiple Oracle installations under /opt and databases are running from different mount points.
    Regards,

  • How to organize the structure of multipanel application

    hi,
    I need to create a multi panel application where must be active only one panel, so my connection to DB have to be passed to an active panel only. So, how can I pass my connection from one panel to another if my panels are created as separate projects with separate application workspaces and are joined to main project as jar libraries.
    thanks

    reg231 wrote:
    how to read the keystrokes of other application[How To Ask Questions The Smart Way|http://www.catb.org/~esr/faqs/smart-questions.html]

Maybe you are looking for

  • HDD Unmounted, can't get it back

    Hi guys, I think this one is my fault, so hopefully some one out there can save me I was using TechTool Pro 4 to scan and optimise the HDD's ... there are 3 x 300gig Maxtors (files and work stuff) & 1 x 120gig WD (programs only) inside. I started to

  • How do I get rid of the quick crossfade in gapless playback?

    I've noticed since installing iTunes 8 that there is a very quick crossfade when tracks progress from one to the other with gapless playback. I don't remember this happening before, although maybe i juts didn't notice this? I do have crossfade disabl

  • Not showing companies

    Hello All, We are using SAP Business one. After entering the User Id and password, companies are not showing in database for one user. Attached the file FYI. Please Help.

  • TC drops connection

    Using TC as wireless base station with a Virgin Media modem. Generally works well, but, if MBP put to sleep, when resumed, TC green light often goes yellow and TC is not detected by AU. After say 30 secs, green light reappears and all's well. Whilst

  • Server Installation

    Dear All, Right now we have OBIEE 10.1.3.4.1 version. Is it possible to install 2 BI server and 2 Presentation server but single oc4j server but different port number. If possible could you pls explain me. If not what the problem? Need to install lin