Passing variables and methods between two class files

I created two simple programs to see what I can learn about how separate class files work together.
There are two files, Alpha.java and Beta.java. Both are located in the same folder.
Here�s Alpha.java:
********* Alpha.java *********
public class Alpha {
public int alphaInt;
public void alphaMethod() {
System.out.println("This is Alpha's alphaMethod.");
******** End Alpha **********
Here�s Beta.java
******** Beta.java ***********
public class Beta {
public static void main() {
Alpha a = new Alpha();
a.alphaInt = 10;
System.out.println(The value of alphaInt is " + a.alphaInt);
a.alphaMethod();
******** End Beta ***********
Alpha compiles fine. Beta does not compile and I get this error:
�Exception in thread �main� java.lang.NoSuchMethodError: main�
My first problem to solve is to get Beta to compile. After that I should be able to run it from the command line and get something like this as output:
�The value of alphaInt is 10�
�This is Alpha�s alphaMethod.�
Would some kind people please help me with this?
TIA,
Logan

That was easy, and it confirms what I thought should happen. Now for the real question:
Alpha and Beta are servlets in a package called abClasses. Alpha starts out like this:
package abClasses;
import javax.servlet.*;
import javax.servlet.jsp.*;
import java.util.*;
import javax.servlet.http.*;
import java.sql.*;
public class Alpha extends HttpServlet {
Beta is the same, except for the name of course.
Alpha creates a Connection variable, and Beta is going to use it. But when I try to compile Alpha I get an error that says this:
cannot resolve symbol
symbol: class Alpha
location: abClasses.Beta
Alpha a = new Alpha();
Any suggestions on why what we did in the simple Alpha and Beta programs won't work in the Alpha and Beta servlets?
You are appreciated,
Logan

Similar Messages

  • Three finger or two finger gesture to move back and forward between pages of file only work on safari, unlike with old os. this new lion won't let me do it. Any help?

    three finger or two finger gesture to move back and forward between pages of file only work on safari, unlike with old os. this new lion won't let me do it. Any help?

    I have decided to dedicate this thread to the wonderful errors of Lion OSX. Each time I find a huge problem with Lion I will make note of it here.
    Today I discovered a new treasure of doggie poop in Lion. No Save As......
    I repeat. No Save As. In text editor I couldn't save the file with a new extension. I finally accomplished this oh so majorly difficult task (because we all know how difficult it should be to save a file with a new extension) by pressing duplicate and then saving a copy of the file with a new extension. Yet then I had to delete the first copy and send it to trash. And of course then I have to secure empty trash because if I have to do this the rest of my mac's life I will be taking up a quarter of percentage of space with duplicate files. So this is the real reason they got rid of Save As: so that it would garble up some extra GB on the ole hard disk.
    So about 20 minutes of my time were wasted while doing my homework and studying for an exam because I had to look up "how to save a file with a new extension in  mac Lion" and then wasted time sitting here and ranting on this forum until someone over at Apple wakes up from their OSX-coma.
    are you freaking kidding me Apple? I mean REALLY?!!!! who the heck designed this?!!! I want to know. I want his or her name and I want to sit down with them and have a long chat. and then I'd probably splash cold water on their face to wake them up.
    I am starting to believe that Apple is Satan.

  • Drag and Drop between two java applications

    Hi,
    I am trying to implement drag and drop between two instances of our java application. When i drop the content on the target, the data flavors are transmitted properly, but i get the exception :
    java.awt.dnd.InvalidDnDOperationException: No drop current
         at sun.awt.dnd.SunDropTargetContextPeer.getTransferData(SunDropTargetContextPeer.java:201)
         at sun.awt.datatransfer.TransferableProxy.getTransferData(TransferableProxy.java:45)
         at java.awt.dnd.DropTargetContext$TransferableProxy.getTransferData(DropTargetContext.java:359)
         at com.ditechcom.consulbeans.TDNDTree.drop(TDNDTree.java:163)
         at java.awt.dnd.DropTarget.drop(DropTarget.java:404)
         at sun.awt.dnd.SunDropTargetContextPeer.processDropMessage(SunDropTargetContextPeer.java:547)
    How can i fix this ?
    Thanks a lot,
    Karthik

    Play with this;-import java.awt.*;
    import java.awt.datatransfer.*;
    import java.awt.dnd.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    // Credit to bbritna who I stole it from in the 'New To ..' Forum
    public class DragComps implements DragGestureListener, DragSourceListener,
                                         DropTargetListener, Transferable{
        static final DataFlavor[] supportedFlavors = { null };
        static{
              try {
                  supportedFlavors[0] = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType);
              catch (Exception ex) { ex.printStackTrace(); }
        Object object;
        // Transferable methods.
        public Object getTransferData(DataFlavor flavor) {
               if (flavor.isMimeTypeEqual(DataFlavor.javaJVMLocalObjectMimeType))
             return object;
               else return null;
        public DataFlavor[] getTransferDataFlavors() {
               return supportedFlavors;
        public boolean isDataFlavorSupported(DataFlavor flavor) {
               return flavor.isMimeTypeEqual(DataFlavor.javaJVMLocalObjectMimeType);
        // DragGestureListener method.
        public void dragGestureRecognized(DragGestureEvent ev)    {
               ev.startDrag(null, this, this);
        // DragSourceListener methods.
        public void dragDropEnd(DragSourceDropEvent ev) { }
        public void dragEnter(DragSourceDragEvent ev)   { }
        public void dragExit(DragSourceEvent ev)        { }
        public void dragOver(DragSourceDragEvent ev) {
               object = ev.getSource(); }
        public void dropActionChanged(DragSourceDragEvent ev) { }
        // DropTargetListener methods.
        public void dragEnter(DropTargetDragEvent ev) { }
        public void dragExit(DropTargetEvent ev)      { }
        public void dragOver(DropTargetDragEvent ev)  {
               dropTargetDrag(ev); }
        public void dropActionChanged(DropTargetDragEvent ev) {
           dropTargetDrag(ev); }
        void dropTargetDrag(DropTargetDragEvent ev) {
               ev.acceptDrag(ev.getDropAction()); }
        public void drop(DropTargetDropEvent ev)    {
               ev.acceptDrop(ev.getDropAction());
                   try {
                       Object target = ev.getSource();
                      Object source = ev.getTransferable().getTransferData(supportedFlavors[0]);
                       Component component = ((DragSourceContext) source).getComponent();
                       Container oldContainer = component.getParent();
                       Container container = (Container) ((DropTarget) target).getComponent();
                       container.add(component);
                       oldContainer.validate();
                       oldContainer.repaint();
                       container.validate();
                       container.repaint();
                   catch (Exception ex) { ex.printStackTrace(); }
                   ev.dropComplete(true);
        public static void main(String[] arg)    {
              JButton button = new JButton("Drag this button");
              JLabel label = new JLabel("Drag this label");
              JCheckBox checkbox = new JCheckBox("Drag this check box");
              JFrame source = new JFrame("Source Frame");
              Container source_content = source.getContentPane();
              source.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              source_content.setLayout(new FlowLayout());
              source_content.add(button);
              source_content.add(label);
              JFrame target = new JFrame("Target Frame");
              Container target_content = target.getContentPane();
              target.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              target_content.setLayout(new FlowLayout());
              target_content.add(checkbox);
              DragComps dndListener = new DragComps();
              DragSource dragSource = new DragSource();
              DropTarget dropTarget1 = new DropTarget(source_content,
              DnDConstants.ACTION_MOVE, dndListener);
              DropTarget dropTarget2 = new DropTarget(target_content,
              DnDConstants.ACTION_MOVE, dndListener);
              DragGestureRecognizer dragRecognizer1 =
              dragSource.createDefaultDragGestureRecognizer(button,
              DnDConstants.ACTION_MOVE, dndListener);
              DragGestureRecognizer dragRecognizer2 =
              dragSource.createDefaultDragGestureRecognizer(label,
              DnDConstants.ACTION_MOVE, dndListener);
              DragGestureRecognizer dragRecognizer3 =
              dragSource.createDefaultDragGestureRecognizer(checkbox,
              DnDConstants.ACTION_MOVE, dndListener);
              source.setBounds(0, 200, 200, 200);
              target.setBounds(220, 200, 200, 200);
              source.show();
              target.show();
    }[/code                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • LOOKUP OF beans between two jar files

    How to lookup beans between two jar file
    I have two jar files named as ejb1.jar , ejb2.jar .
    both the <ejb-name> are same..
    InitialContext ctx = new InitialContext();
    Object te = ctx.lookup("test");
    if i want to lookup for 2nd jar (ejb2.jar)which has the same <ejb-name> how to do..
    helpp !!!!!!!
    prakash

    Hi,
    No it would not be possible to differentiate the data just by using the dump files. You need to import these dump files in the database and then you can compare it for any difference.
    Regards
    Anurag

  • How does the ADF support romote call method between two managed server ?

    How does the ADF support romote call method between two managed server ?

    You would usually use this as a WebService through the WSDL that is exposed.
    JDeveloper can help you create a Java Proxy to call the Web service if you point it to the WSDL file that was generated for your AM.
    Some other samples here:
    http://www.connotea.org/user/jdeveloper/tag/Service%20Interface

  • How to find the arguments of a static method from the class file

    Hi,all !
    How to find the arguments of a static method from the class file? for example, when we meet a bytecode "invokestatic", how can I know the arguments of this static method?

    Hi,all !
    How to find the arguments of a static method from the
    class file? for example, when we meet a bytecode
    "invokestatic", how can I know the arguments of this
    static method?You mean
    1. The values?
    2. Argument names?
    3. Argument signatures.
    I would suppose for the last that the easiest way would be to parse the signature string.
    The first is not possible - not from the class file.
    The second is only in the debug information stored in the optional part of the class file. And figuring out the format for that is going to be a problem.

  • A basic question about static variables and methods

    What would be the effects if I declare lots of static variables and static methods in my class?
    Would my program run faster?
    Would the class take more memory spaces? (If so, how do I estimate an appropriate number of variabls and methods to be declared static?)
    Thank you @_@

    when you declare a static var the var isn't created for every instance of the class, it just "live" in the class
    when you declare a static method is the same, so if you have:
    class MyClass
    static int myMethod()
    //Method work
    you dont need to have a instance of the class to call myMethod, you can do such things like this.
    int value = Myclass.myMethod();
    if myMethod isn't static you can't do this.. so, if
    class MyClass
    int myMethod()
    //Method work
    you CAN'T call
    int value = MyClass.myMethod();
    instead, you have to write
    MyClass m;
    m = new MyClass();
    value = m.myMethod();

  • How to Persis session between two ear files

    Can anybody tell me how to persists session between two ear files?
    Please Help its urgent!!
    Rahul

    Rahul -- there's nothing as a J2EE spec requirement or even a proprietary feature of OC4J/OracleAS which will enable this.
    If you have two different EAR files, then they are two different applications, and each will have their own session which can't be shared amongst each other.
    If you have data which needs to be shared across different applications then you could either put it on a shared file system or write it to a database which you can then read from in the other application.
    One way to do this is to implement the HttpSessionAttributeListener interface which will be called when object are added/removed/updated from a session, and then make a determination on whether the new object needs to be stored in a common place to facilitate sharing between applications.
    This is more likely to be a hackaround and ideally you'd examine why you want to share session state across applications and rearchitect so you don't need to do it -- but if you want to try a solution without a major revisiting of the whole application, then perhaps it's an option.
    cheers
    -steve-
    cheers
    -steve-

  • Can i share music and photos between two users on the same machine?

    How can I share my music and photos between two users on the same machine?

    Thank you Joe - I tried this but it's only showing a teensy amount of music - the stuff on the second users account as opposed to the giagntic library on the 'main' account. I actually went to a Genius Bar and they said that apple doesn't really want you to share music between accounts - parents don't want to hear their kids music etc. Which seemed strange, but it might be the case sadly   Thanks anyway!

  • HT204053 how do I share calendars and music between two ID's?

    How do I share calendars and music between two Apple ID's?  We have a Mac Pro and two Iphones.  Currently we utilize one ID between the Iphones in order to sync the calendars and music.

    You can privately share a calendar between devices using different iCloud IDs as explained here: http://help.apple.com/icloud/#mm6b1a8694.  Even if your devices use different IDs for iCloud you can continue to share the same ID for iTunes to share your music and other purchased media.  The ID you use on a device for iCloud does not need to be the same as the ID used for iCloud.

  • Drag and Drop between two windows

    I would like to implement Drag and Drop between two windows for example in Windows I can take URL Address form browser and drag it and drop it in to any control that excepts String like TextField.
    I would like to have the same behavior with my Java Text Controls.
    What can I do to achieve this?

    There is no configuration for it. It should work.
    Can you try it in a different user account. If it works in a different account, then it is likely something in your current user account that is messed up. If it doesn't work in another user account, then it is likely something with Mail, itself. 
    You could try downloading and installing the 10.6.7 combo update. That may repair what is wrong.

  • Drag and Drop between two JTables

    I tried to implement drag and drop between two JTables using data transfer, but i did not get it to work, that dnd works in both directions. i have my own transferhandler, but if is use setTransferHandler(handler), i'm no longer able to start a drag from that table. i also tried to use a mouse listener to call exportAsDrag, but i only works in one direction. any ideas or examples?

    That is a rather large request, and indicates that you have likely not spent much time researching the subject before posting. Read up on Swing drag & drop here (http://java.sun.com/docs/books/tutorial/dnd/), then ask specific questions about something you don't understand, problems with your implementation, etc.
    Mike

  • Drag and drop between two different browser

    Hi All,
    Is drag and drop in flex possible behind boundaries of
    browser context?.
    Currently i have a vdividebox which contains two datagrid
    with drag and drop functionality.
    Now I want to display this datagrid in two different browsers
    and provide the drag and drop functionality between them.
    Is their any way to achieve this?
    Thanks.

    Hey
    due to Security restrictions (Sandbox) I don't believe that
    you can Drag and Drop between two Browsers with Flex, maybe this
    can be done with AIR.
    Cheers
    Dietmar

  • Drag and Drop between two list boxes

    Hi all
    I am working over Drag and Drop .. i have to implement Drag and Drop between two list boxes .. both list box exist in same page ..each list box have number of rows.. please give me some idea ... as i am new for JSP and Servlet...
    Thanks in advance
    Regards
    Vaibhav

    Hi all
    I am working over Drag and Drop .. i have to
    implement Drag and Drop between two list boxes ..
    both list box exist in same page ..each list box have
    number of rows.. please give me some idea ... as i am
    new for JSP and Servlet...
    Something close to what you are looking for is Select Mover in Coldtags suite:
    http://www.servletsuite.com/jsp.htm

  • Can someone please help, I have a dvd disk containing lecture videos, on a Windows pc it works fine, and the disk opens to the dvd menu. However on my macbook pro running Mountain Lion, it opens as a data disk, with video and audio in two seprate files??

    Can someone please help, I have a dvd disk containing lecture videos, on a Windows pc it works fine, and the disk opens to the dvd menu. However on my macbook pro running Mountain Lion, it opens as a data disk, with video and audio in two seprate files??

    You may need a 3rd party application to view the DVD in a wWindows format such as
    http://flip4mac-3.en.softonic.com/mac
    https://www.macupdate.com/app/iphone/5758/vlc-media-player

Maybe you are looking for