Creating java bean

Hi all,
I am stuck with my first java bean, can anyone please help!? I've serahed the net and this forum, but the closest one to my problem that I can find is this one, http://forum.java.sun.com/thread.jspa?threadID=571292&messageID=2850205. However, it does not help me much. The following are the steps that I took.
Thanks,
Welles
1. Create a class
package testBeans;
public class TestClass
     public static void main(String[] args)
          System.out.println("Hello World!");
     public void runTest(){
2. Complie the java file to the testBeans folder under the current folder
c:\work>javac -d . TestClass.java
3. Create the jar file
c:\work>jar cvf testBeans.jar testBeans/*.*
added manifest
adding: testBeans/TestClass.class(in = 483) (out= 315)(deflated 34%)
4. Put the testBeans.jar in C:\Program Files\Java\jdk1.5.0_01\jre\lib\ext
5. Create a driver class
import testBeans.*;
public class BeanDriver
     public static void main(String[] args)
          TestClass.runTest();
6. Complie the BeanDriver.java file, but I get the following error message :(
---------- javac ----------
C:\test\BeanDriver.java:7: cannot access TestClass
bad class file: .\TestClass.java
file does not contain class TestClass
Please remove or make sure it appears in the correct subdirectory of the classpath.
          TestClass.runTest();
^
1 error
Output completed (0 sec consumed) - Normal Termination

Crossposted, so don't anyone waste their time answering it here. Answer over here instead:
http://forum.java.sun.com/thread.jspa?threadID=624016
@OP: Crossposting is rude.

Similar Messages

  • Create Java bean for a http session

    how can i create a java bean for an http session. also is it possible to access it from another java class within that session

    Try the following forum (about JSP technology)
    http://forum.java.sun.com/forum.jspa?forumID=45

  • Need urgent help on Java Bean

    Can some one help me to find a place for step by step documentation on how to create java bean and load an image thru java Bean on a form. I'm not loading from the same server it must be loaded from a different server.
    Very urgent please. I really appreciate any help.
    Thanks in advance.

    Hi,
    for the first part of your question: start Forms Builder, press F1 and the seach for Bean Area. The online help also comes with code examples
    for the second part, this URL will give you a head start: http://www.particle.kth.se/~lindsey/JavaCourse/Book/Java/Chapter11/loadingImages.html
    Frank

  • Expose EJB through Java Bean model importer in Web Dynpro

    Hi,
    I am planning to expose EJB like following:
    1. Create Stateless session bean as a façade for DAO access.
    2. Create DAO to access database. In my case is Oracle DB
    3. Create Java Bean to encapsulate session bean
    4. Import java bean model to web dynpro
    Few of my business method return the object array e.g. Customer[] which contains all properties of customer, and getter, setter.
    Has anyone done this before? Is there any sample code?
    Best Regards,
    Zhang Yan

    Hi
    I think u can refer to the following link
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/java/simple java bean generator for database.pdf
    Thought this link is also Useful
    Creating and Deploying Web Services for an EJB
    Wishes
    Krishna kanth

  • Writing java bean class?

    Hi All,
    In my scenario,I am getting all pagelevel details from the database.
    I mean Suppose in my web application 10 pages are there.for 10 pages, all details (like page title,button names,page header etc) based on user.per user it will vary .Some body have insert,update buttons ,some body not.
    I was created java bean with static getters and setters for all pages to get the data and store.
    I don't want to connect to the database to get the page details per every page.so,
    its working for me.what happen if more than one user access the application.The details will effect to all when new user enter into the system?
    any suggestions.....................................????
    if I write non - static getters and setters ,I need to instantiate everypage.
    its takes more memory ,In my web application I have above 75 pages.
    solution???

    1)So,I need to pass the Class object to the
    session.setAttribute()
    right?
    Well to be precise - you create an instance of the class (object) for each registered and logged in user and then yes - store the object as a session attribute
    >
    2)Suppose I change my bean to instance bean,bean have
    above 20 instance variables .I think performance
    point of view,Its not good.
    Because,if users are more than 20 what happend?
    You should probably think about 200 :). 20 users is not an issue wwhen you have sufficient hardware.
    One option would be to store the user permission/preferences in the db and associate it with the user id. Infact for large applications that hold lots of user related data per user, that would be my preferred approach.
    ram.

  • Generate Java Bean Steleton with WSDL error

    Hi everyone:
    We are using CE 7.1 EHP1 SP01. We use ESR to create model and use NWDS to create java Bean Steleton for ESR model. It works fine in CE7.1. But when we upgrade to CE7.1 EHP1 SP01. An error occurs. When we create the skeleton. We find an error in the wsdl. The error is like "The 'EmbeddedSupport' port type specified for the  'EmbeddedSupportBinding' binding is undefined. Check the 'EmbeddedSupport' port type name and ensure it is defined."
    Due to everything is generated automatically by Java Bean skeleton wizard. I think there is sth wrong with ESR wsdl. Does anyone encount this issue?
    Thanks
    Elliot

    Hi,
    you have to delete some tags.
    k.      When imported, the wsdl file is validated. Open the wsdl file to check the errors.
    If you get the following error: '<Your service>_In' port type specified for the '<Your Service Binding>' binding is undefined.  Delete the policy tag wsp:Policy under the tag wsdl:portType and under the tag wsdl:binding.
    This is an extract of the blog:
    /people/abdelmorhit.elrhazi/blog/2009/10/30/how-to-consume-an-inbound-backend-web-service-in-nwdsjboss-environment
    Regards,
    Christoph

  • Is there any way to create objects in jstl even if its not a java bean

    please someone help me :<(
    thx in advance for the time you'll spend on my question.
    i am translating some code in jsp with embedded java to jstl. and in scriptlets they created java object of some class and using it in loop. but that class is not bean, so i can't use <jsp:useBean> tag so how do i do that here is the code
    <% TabLayoutConfiguratorImpl tabsConfigurator = new TabLayoutConfiguratorImpl();
    %>
    <logic:iterate id="tab" name="tabList" type="TabItem" >
    <% // compute href
    if (!tabsConfigurator.isHidden(tab))
    -----statements-----
    %>
    </logic:iterate>
    how can i create TabLayoutConfiguratorImpl class object and use everything should be done in jstl? is there any way at all?
    here is my class
    package conf;
    import javax.servlet.http.*;
    import org.apache.struts.tiles.ComponentContext;
    public class TabLayoutConfiguratorImpl implements TabLayoutConfigurator
    public void configure(HttpServletRequest request) {
    HttpSession session = request.getSession();
    ComponentContext context = ComponentContext.getContext(request);
    this.configureDefinition(context);
    java.util.Iterator i = ((java.util.List) context.getAttribute("tabList")).iterator();
    while (i.hasNext())
    TabItem tab = (TabItem) i.next();
    this.configureTab(tab, session);
    // subclasses should override this if there the attributes in the Definition
    // need to be manipulated
    protected void configureDefinition(ComponentContext context)
    // default implementation does nothing
    // subclasses should override this if tabs in the definition
    // need to be manipulated
    protected void configureTab(TabItem tab, HttpSession session)
    // default implementation does nothing
    // subclasses should override this if they want to hide tabs in the
    // configuration
    public boolean isHidden(TabItem tab)
    // default implementation returns false - ie they are visible
    return false;
    }

    I don't see what is wrong with
    <jsp:useBean id="tabsConfigurator" class="com.mypackage.TabLayoutConfiguratorImpl"/>
    The class has a no-args constructor at least. The useBean tag will work with it. Probably.
    But still, some code just can't be translated into scriptless JSTL.
    Calling methods which take parameters is one of those things.
    In this case you probably want to write a custom tag to work with your tabs
    I would probably look at using custom tags like this:
    <%@ taglib prefix="tab" uri="/WEB-INF/TabLayout.tld"%>
    // tab to create the configurator.
    // either export it as a var, or use other tags only nested within this one
    // so you can get access to the configurator.
    <tab:configure var="configurator">
      <tab:render configurator="${configurator}" tab="${tab}">
    </tab:configure>I don't know exactly what the scriptlet code will be doing. But I think a custom taglib would be the only way to eliminate scriptlet code that you have here.

  • Creating XML file from Java Bean

    Hi
    Are there any standard methods in Java 1.5 to create XML file from java bean,
    i can use JAXB or castor to do so,
    But i would like to know if there is any thing in java core classes,
    I have seen XMLEncoder, but this is not what i want.
    Any ideas
    Ashish

    Marshall JavaBean to an XML document with JAXB or XMLBeans.

  • Create XML dynamically from schema and Java bean

    Hi,
    I'm looking for suggestions on the best approach to create an XML file programatically from a schema and Java bean.
    The schema used is not fixed and may vary with each request so a dynamic way to create the XML is required.
    Is there an API available that allows me to achieve this easily? Any help would be appreciated to point me in the right direction.
    Thanks.

    XMLBeans or JAXB should work for you.
    - Saish

  • Using java.beans.EventHandler to create javafx.event.EventHandler instances

    One thing I do not like about the JavaFX EventHandler is all the anonymous classes that need to be created. This messes up the way the code looks and I heard that creating all these anonymous classes adds to the total number of classes that get loaded.
    In searching for a way around this I found java.beans.EventHandler's create method. This method (there are a few variations of it) its suppose to provide a one liner to create anonymous implementations of listener interfaces (like JavaFX's EventHandler). So I decided to try it out against some of the sample JavaFX code that is out there.
    I used.... http://docs.oracle.com/javafx/2.0/events/KeyboardExample.java.htm... as my test code.
    I replaced...
            private void installEventHandler(final Node keyNode) {
                // handler for enter key press / release events, other keys are
                // handled by the parent (keyboard) node handler
                final EventHandler keyEventHandler = new EventHandler<KeyEvent>() {
                    @Override
                    public void handle(final KeyEvent keyEvent) {
                        if (keyEvent.getCode() == KeyCode.ENTER) {
                            setPressed(keyEvent.getEventType() == KeyEvent.KEY_PRESSED);
                            keyEvent.consume();
                keyNode.setOnKeyPressed(keyEventHandler);
                keyNode.setOnKeyReleased(keyEventHandler);
            }with....
            private void installEventHandler(final Node keyNode) {
                // handler for enter key press / release events, other keys are
                // handled by the parent (keyboard) node handler
                final EventHandler keyEventHandler = (EventHandler)java.beans.EventHandler.create(EventHandler.class, this, "handle", "");
                keyNode.setOnKeyPressed(keyEventHandler);
                keyNode.setOnKeyReleased(keyEventHandler);
    public void handle(final KeyEvent keyEvent) {
                if (keyEvent.getCode() == KeyCode.ENTER) {
                    setPressed(keyEvent.getEventType() == KeyEvent.KEY_PRESSED);
                    keyEvent.consume();
            }It worked. The new code behaved just like the old code.
    One caveat though. The class count did in fact go up by about 20 classes. I ran multiple runs and this was true for all of them. But I only applied this technique on one anonymous class. It could be the case that the real savings in class count come after many instances of swapping out anonymous classes with this technique.
    From the javadoc
    "Also, using EventHandler in large applications in which the same interface is implemented many times can reduce the disk and memory footprint of the application.
    The reason that listeners created with EventHandler have such a small footprint is that the Proxy class, on which the EventHandler relies, shares implementations of identical interfaces. For example, if you use the EventHandler create methods to make all the ActionListeners in an application, all the action listeners will be instances of a single class (one created by the Proxy class). In general, listeners based on the Proxy class require one listener class to be created per listener type (interface), whereas the inner class approach requires one class to be created per listener (object that implements the interface)."
    Edited by: jmart on Apr 23, 2012 2:13 AM

    Well, the idea is that with Java 8 they can be rewritten to something like this:
    private void installEventHandler(final Node keyNode) {
                // handler for enter key press / release events, other keys are
                // handled by the parent (keyboard) node handler
                EventHandler keyEventHandler = keyEvent => {
                        if (keyEvent.getCode() == KeyCode.ENTER) {
                            setPressed(keyEvent.getEventType() == KeyEvent.KEY_PRESSED);
                            keyEvent.consume();
                keyNode.setOnKeyPressed(keyEventHandler);
                keyNode.setOnKeyReleased(keyEventHandler);
            }Basically what you are doing now is sacrificing performance (both in real performance and in a lot of extra garbage created) for a little bit of memory gain. Unless you have good reasons and measurements to back this up I think this would definitely qualify as premature optimization.
    I'm a heavy user of anonymous inner classes myself, having several hundreds of them now in my project and I have yet to run into problems. I often write code like the example below purely for readability and convience:
    Set<String> someSet = new HashSet<>() {{
      add("A");
      add("B");
    new HBox() {{
      getChildren.add(new VBox() {{
        getChildren.add(new Label("Hi"));
      getChildren.add(new VBox() {{
        getChildren.add(new Label("There"));
    }};

  • Creating DAO layer from java beans(setter and getter methods)

    Can anybody explain me how to create an adapter layer (DAO layer) from java beans with no connection and transaction code inside DAO layer?

    Sure, have another layer do the transaction work.
    Your DAO would make us of this layer.

  • Create a web service from java bean and map exceptions to SOAP faults

    Hi,
    We have to expose our Session stateless EJB3 as web services. I've tried to use annotations and jdev wizard "java bean to web service" and it works fine.
    Our problem now is that our methods can throw a business exception that contains a list of error message strings to be presented on the client.
    I did not find any way to use annotations to make it build a wsdl with soap fault mapped to our exception class. Neither I could to make the wizard to create wsdl with faults.
    As we are exposing already designed and implemented classes as web services, I think the bottom-top (java->wsdl) approach is better that top->botton (wsdl->java). Therefore, I'm looking for a possibility to generate the web services from the java beans and have the exception be mapped to a soap fault message.
    We are using jdev 10.1.3.1 and OAS 10.1.3.1., is there a way to map exceptions to soap faults using bottom->top approach?
    thank you

    A couple of links that may be of help:
    http://www.netbeans.org/servlets/ReadMsg?listName=nbj2ee&msgNo=1218
    My last question concerning web services:
    I have already written a session bean and I'd like to add some methods
    as a web service to it, how do I do that?
    Or I can only create another bean for a webservice and cannot modify the
    original one?You might create web service with existing sources and select you bean. New web services with appropriate lookup method will be generated.
    All web service method, that will be exposed in web service, you
    should add itself (Pop-up menu Web Service -> Add operation)
    http://usersguide.netbeans.org/files/documents/40/73/Chapter9-WebServices.pdf

  • Creating a Java Beans

    Hi,
    Iam trying to create a beans to which works as line control ...so wat i want to do after creating the beans ...i have created a program which will work as a line control in run time....but i want to do the same in the design time as a bean.,..can anyone clarify my doubt ....

    Hi,
    Iam trying to create a beans to which works as line control ...so wat i want to do after creating the beans ...i have created a program which will work as a line control in run time....but i want to do the same in the design time as a bean.,..can anyone clarify my doubt ....

  • Is it possible to create crystal reports on IBM RAD with Java Bean as Data Source

    <p>Hi,</p><p>&#160;</p><p>          Our company wants report generation in IBM RAD 7.0  using crystal reports with a Java Bean as data source. i HAVEN&#39;T FOUND ANY ARTICLES TO WORK ON RAD. Any inputs appreciated..</p><p>&#160;</p><p>Thanks,</p><p>Manju</p>

    Look for Java POJO in the doc, i'm using RAD 7.0 and it's working like RAD 6.0

  • How can I create a java bean instance from servlet, at runtime?

    Will anybody help me?
    I want to send bean (class) name to a servlet through parameter and I need servlet to create specified bean instance and run its method that I will send through another parameter, at runtime.

    Thanks. I found answer

Maybe you are looking for

  • Apple Mini-DVI to VGA Adapter Problems in Boot Camp / Windows

    I currently run Windows XP SP2 on my MacBook and recently purchased the Mini-DVI to VGA adapter so I could hook up the MacBook to an external projector, monitor, or TV to display what's on my Windows screen on the external device. However, when I con

  • I keep getting certificate errors even on apple pages

    I have a macbook pro 13 retina disply (OS10) and no matter what page I want to pull up safari give me the message that safari can't verrify the identity of the website. when i look at the certificate it says the the certificate is not yet valid. I ha

  • Make a field Unchangeble in Task List

    Hi Friends,                 Can anybody help in making the field RIHSTPX-MEINS (which is basiccaly the component Unit of Measure field ) in the Component page of a Task List.The Issue here is that the users are able to change the UOM value and can be

  • JTable with editable JComboBoxes

    For some reason once I added editable JComboBoxes to a JTable I can no longer tab among the fields in the table. If I just select a cell, I can tab to the other cells in that row, and then to proceeding rows as I reach the end of each. However if I d

  • New mac pro is death

    Hi there, i bought a brand new mac pro 3.2 quad core with 8gb ram i install protools 7.4 with protools hd3 pcie cards, i run it perfectly untill i install the midi and audio drivers of a tascam interface then my protools sessions didnt worked, so i j