Problem with constructor

Hi guys
when i created this constructor, it keep throwing back this error whcih i don't understand.
public interface MyNumber {
// data defination
     private int wholenumber = 0;
     private float fraction = 0;
// constructor
public MyNumber(int whole, float fract) {
     wholenumber = whole;
     fraction = fract;
may i know what is wrong with my constructor code?
it keep saying <identifier>> expected

part b of the question has ask for an interface class
any problem with my code?
public class MyNumber {
// data defination
     private int wholenumber = 0;
     private float fraction = 0;
// constructor
public MyNumber(int whole, float fract) {
     wholenumber = whole;
     fraction = fract;
// methods or operations
     public MyNumber add(MyNumber c, MyNumber d){
          int r = wholenumber + c.getWholeNumber();
          float i = fraction + c.getFraction();
          MyNumber newC = new MyNumber(r,i);
          //MyNumber newD = new MyNumber(i);
          return newC;
          //return newD;
     public MyNumber subtract(MyNumber c, MyNumber d){
          int r = wholenumber - c.getWholeNumber();
          float i = fraction - c.getFraction();
          MyNumber newC = new MyNumber(r,i);
          //MyNumber newD = new MyNumber(i);
          return newC;
          //return newD;
     public MyNumber multiply(MyNumber c, MyNumber d){
          int r = wholenumber * c.getWholeNumber();
          float i = fraction * c.getFraction();
          MyNumber newC = new MyNumber(r,i);
          //MyNumber newD = new MyNumber(i);
          return newC;
          //return newD;
     public int getWholeNumber(){
          return wholenumber;
     public float getFraction(){
          return fraction;
}

Similar Messages

  • Problems with constructors

    Hi guys im having problems with constructors. I get the following error:
    package\Cat5500IfXDescr.java:60: cannot resolve symbol
    symbol : constructor IfXDescrScanner(java.net.Inet,java.lang.String,java.lang.String,differentPackage.SNMPCommandObserver)
    location: class package.IfXDescrScanner
    super( InetAddress.getByName( device.getIpAddress()),
    I have a class SNMPCommand
    I have a class IfDescrScanner which extends SNMPCommand
    I have a class Cat5500IfXDescr which extends IfDescrScanner
    Here are the respective constructors:
         public SNMPCommand( InetAddress agentAddress, String readCommunityString,
                                  String writeCommunityString, SNMPCommandObserver observer ){
              peer = new SnmpPeer( agentAddress );
              peer.getParameters().setReadCommunity( readCommunityString );
              peer.getParameters().setWriteCommunity( writeCommunityString );
              this.observer = observer;
         public SNMPCommand( InetAddress agentAddress, SNMPCommandObserver observer ){
              peer = new SnmpPeer( agentAddress );
              this.observer = observer;
         public IfXDescrScanner(Device device, SNMPCommandObserver observer )
         throws UnknownHostException{
              super(      InetAddress.getByName( device.getIpAddress()),
                        device.getReadCommunityString(),
                        device.getWriteCommunityString(),
                        observer );
        public Cat5500IfXDescr( Device device, SNMPCommandObserver observer )
         throws UnknownHostException{
              super(      InetAddress.getByName( device.getIpAddress()),
                        device.getReadCommunityString(),
                        device.getWriteCommunityString(),
                        observer );
         }You'll notice SNMPCommand has 2 constructors. i get no error when i call super to the SNMPCommand constructor from IfXDescrScanner however when i call it from Cat5500IfXDescr i get the error. Is what i am doing illegal. Anyone any ideas on how i solve this. Thanks
    Joe.

    From what I see in a single look, you are passing an object of java.net.Inet to the constructor and the constructor takes InetAddress object as parameter.
    Just check it.
    Hi guys im having problems with constructors. I get
    the following error:
    package\Cat5500IfXDescr.java:60: cannot resolve
    symbol
    symbol : constructor
    IfXDescrScanner(java.net.Inet,java.lang.String,java.la
    ng.String,differentPackage.SNMPCommandObserver)
    location: class package.IfXDescrScanner
    super( InetAddress.getByName(
    device.getIpAddress()),
    I have a class SNMPCommand
    I have a class IfDescrScanner which extends
    SNMPCommand
    I have a class Cat5500IfXDescr which extends
    IfDescrScanner
    Here are the respective constructors:
         public SNMPCommand( InetAddress agentAddress,
    String readCommunityString,
    String writeCommunityString,
    tring, SNMPCommandObserver observer ){
              peer = new SnmpPeer( agentAddress );
    peer.getParameters().setReadCommunity(
    y( readCommunityString );
    peer.getParameters().setWriteCommunity(
    y( writeCommunityString );
              this.observer = observer;
    public SNMPCommand( InetAddress agentAddress,
    , SNMPCommandObserver observer ){
              peer = new SnmpPeer( agentAddress );
              this.observer = observer;
         public IfXDescrScanner(Device device,
    SNMPCommandObserver observer )
         throws UnknownHostException{
    super(      InetAddress.getByName(
    e( device.getIpAddress()),
                        device.getReadCommunityString(),
                        device.getWriteCommunityString(),
                        observer );
        public Cat5500IfXDescr( Device device,
    SNMPCommandObserver observer )
         throws UnknownHostException{
    super(      InetAddress.getByName(
    e( device.getIpAddress()),
                        device.getReadCommunityString(),
                        device.getWriteCommunityString(),
                        observer );
         }You'll notice SNMPCommand has 2 constructors. i get
    no error when i call super to the SNMPCommand
    constructor from IfXDescrScanner however when i call
    it from Cat5500IfXDescr i get the error. Is what i am
    doing illegal. Anyone any ideas on how i solve this.
    Thanks
    Joe.

  • Problem with constructors and using public classes

    Hi, I'm totally new to Java and I'm having a lot of problems with my program :(
    I have to create constructor which creates bool's array of adequate size to create a sieve of Eratosthenes (for 2 ->n).
    Then it has to create public method boolean prime(m) which returs true if the given number is prime and false if it's not prime.
    And then I have to create class with main function which chooses from the given arguments the maximum and creates for it the sieve
    (using the class which was created before) and returns if the arguments are prime or not.
    This is what I've written but of course it's messy and it doesn't work. Can anyone help with that?
    //part with a constructor
    public class ESieve {
      ESieve(int n) {
    boolean[] isPrime = new boolean[n+1];
    for (int i=2; i<=n; i++)
    isPrime=true;
    for(int i=2;i*i<n;i++){
    if(isPrime[i]){
    for(int j=i;i*j<=n;j++){
    isPrime[i*j]=false;}}}
    public static boolean Prime(int m)
    for(int i=0; i<=m; i++)
    if (isPrime[i]<2) return false;
    try
    m=Integer.parseInt(args[i]);
    catch (NumberFormatException ex)
    System.out.println(args[i] + " is not an integer");
    continue;
    if (isPrime[i]=true)
    System.out.println (isPrime[i] + " is prime");
    else
    System.out.println (isPrime[i] + " is not prime");
    //main
    public class ESieveTest{
    public static void main (String args[])
    public static int max(int[] args) {
    int maximum = args[0];
    for (int i=1; i<args.length; i++) {
    if (args[i] > maximum) {
    maximum = args[i];
    return maximum;
    new ESieve(maximum);
    for(int i=0; i<args.length; i++)
    Prime(i);}

    I've made changes and now my code looks like this:
    public class ESieve {
      ESieve(int n) {
       sieve(n);
    public static boolean sieve(int n)
         boolean[] s = new boolean[n+1];
         for (int i=2; i<=n; i++)
    s=true;
    for(int i=2;i*i<n;i++){
    if(s[i]){
    for(int j=i;i*j<=n;j++){
    s[i*j]=false;}}}
    return s[n];}
    public static boolean prime(int m)
    if (m<2) return false;
    boolean x = sieve(m);
    if (x=true)
    System.out.println (m + " is prime");
    else
    System.out.println (m + " is not prime");
    return x;}
    //main
    public class ESieveTest{
    public static int max(int[] args) {
    int maximum = args[0];
    for (int i=1; i<args.length; i++) {
    if (args[i] > maximum) {
    maximum = args[i];
    return maximum;
    public static void main (String[] args)
    int n; int i, j;
    for(i=0;i<=args.length;i++)
    n=Integer.parseInt(args[i]);
    int maximum=max(args[]);
    ESieve S = new ESieve(maximum);
    for(i=0; i<args.length; i++)
    S.prime(i);}
    It shows an error for main:
    {quote} ESieveTest.java:21: '.class' expected
    int maximum=max(args[]); {quote}
    Any suggestions how to fix it?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Problems with constructors? can anyone help

    I want to use the Math.random() class to generate a random number
    to fill an array.In the 2 constructors i have this:
    private int[] rand;
    public Randomize(int ra[])
    {rand = new int[7];}
    public Randomize()
    {Math.random();}
    *note ra is a formal parameter
    but nothing happens. The array rand does not fill up with random numbers
    how can i fill it up with random numbers?

    Hi Mike,
    The Math.random() is a static method that returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0.
    It does not return an array or a int. If you use the Math.random method, you will have to cast your double into an int. Also you need to create a for loop to fill your array and add code to check that the value returned from the Math.random method has not already been used.

  • Problem with constructor of inner class.

    Hi everybody!
    I have an applet which loads images from a database.
    i want to draw the images in a textarea, so i wrote an inner class, which extends textarea and overrides the paint method.
    but everytime i try to disply the applet in the browser this happens:
    java.lang.NoClassDefFoundError: WohnungSuchenApplet$Malfl�che
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:1590)
    at java.lang.Class.getConstructor0(Class.java:1762)
    at java.lang.Class.newInstance0(Class.java:276)
    at java.lang.Class.newInstance(Class.java:259)
    at sun.applet.AppletPanel.createApplet(AppletPanel.java:567)
    at sun.plugin.AppletViewer.createApplet(AppletViewer.java:1778)
    at sun.applet.AppletPanel.runLoader(AppletPanel.java:496)
    at sun.applet.AppletPanel.run(AppletPanel.java:293)
    at java.lang.Thread.run(Thread.java:536)
    so my class has no own constructor, it just has the paint method overwritten.
    my class looks like this:
    public class Malfl�che extends javax.swing.JTextArea{
    public void paint(Graphics g){
    Color grey=new Color(220,220,220);
    g.drawImage(img,10,10,null);
    how should a constructor for this class look like?
    sorry i am quite new to this, so i really dont have a clue!
    my class does not have any attributes or requires any so it doesnt need a constructor, doesnt it?
    thanks a lot
    tim

    First off, unlike regular classes, inner classes can be declared public, private, protected, and default.
    Secondly, why are you using the JTextArea to display an image, why not use a JLabel, which takes an Image object as its constructor.
    Thirdly, when you drew your image you did not give it a width and height
    g.drawImage(img, 0,0, img.getWidth(null), img.getHeight(null), null);
    otherwise it will make your image 1 X 1 pixels. not big enough to see.

  • What is the problem with constructor?......

    class sam
    private String name;
    private String desgn;
    public sam(String s){ name=s; }
    public void showName(){ System.out.println(" Name "+name); }
    public void setDesgn(String d){ desgn=d; }
    public void showDesgn(){ System.out.println(" Designation "+desgn); }
    class samp1 extends sam {
    private String Name;
    private String degree;
    public samp1(String s){  
    Name=s;
    public void showName(){ System.out.println(" Name "+Name); }
    public void setDegree(String d){ degree=d; }
    public void showDegree(){ System.out.println(" Degree "+degree); }

    If you want the sam constructor to be called you'll
    have to put in
    super(s);To elaborate a bit...
    Here are the rules for constructors--"ctors" because I'm lazy. Also, because I'm lazy, "super(...)" and "this(...)" mean any super or this call, regardless of how many args it takes, including those that take no args.
    1) Every class has at least one ctor.
    1.1) If you do not define an explicit constructor for your class, the compiler provides a implicit constructor that takes no args and simply calls super().
    1.2) If you do define one or more explicit constructors, regardless of whether they take args, then the compiler no longer provides the implicit no-arg ctor. In this case, you must explicitly define a public MyClass() {...} if you want one.
    1.3) Constructors are not inherited.
    2) The first statement in the body of any ctor is either a call to a superclass ctor super(...) or a call to another ctor of this class this(...) 2.1) If you do not explicitly put a call to super(...) or this(...) as the first statement in a ctor that you define, then the compiler implicitly inserts a call to super's no-arg ctor super() as the first call. The implicitly called ctor is always super's no-arg ctor, regardless of whether the currently running ctor takes args.
    2.2) There is always exactly one call to either super(...) or this(...) in each constructor, and it is always the first call. You can't put in more than one, and if you put one in, the compiler's implicitly provided one is removed.

  • Problems with java constructor: "inconsistent data types" in SQL query

    Hi,
    I tried to define a type "point3d" with some member functions, implemented in java, in my database. Therefor I implemented a class Point3dj.java as you can see it below and loaded it with "loadjava -user ... -resolve -verbose Point3dj.java" into the database.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    package spatial.objects;
    import java.sql.*;
    public class Point3dj implements java.sql.SQLData {
    public double x;
    public double y;
    public double z;
    public void readSQL(SQLInput in, String type)
    throws SQLException {
    x = in.readDouble();
    y = in.readDouble();
    z = in.readDouble();
    public void writeSQL(SQLOutput out)
    throws SQLException {
    out.writeDouble(x);
    out.writeDouble(y);
    out.writeDouble(z);
    public String getSQLTypeName() throws SQLException {
    return "Point3dj";
    public Point3dj(double x, double y, double z)
    this.x = x;
    this.y = y;
    this.z = z;
    public static Point3dj create(double x, double y, double z)
    return new Point3dj(x,y,z);
    public double getNumber()
         return Math.sqrt(this.x*this.x + this.y*this.y + this.z*this.z);
    public static double getStaticNumber(double px, double py, double pz)
         return Math.sqrt(px*px+py*py+pz*pz);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Additionally, I created the corresponding type in SQL by
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    CREATE OR REPLACE TYPE point3dj AS OBJECT EXTERNAL NAME
    'spatial.objects.Point3dj' LANGUAGE JAVA USING SQLDATA (
    x FLOAT EXTERNAL NAME 'x',
    y FLOAT EXTERNAL NAME 'y',
    z FLOAT EXTERNAL NAME 'z',
    MEMBER FUNCTION getNumber RETURN FLOAT
    EXTERNAL NAME 'getNumber() return double',
    STATIC FUNCTION getStaticNumber(xp FLOAT, yp FLOAT, zp FLOAT) RETURN FLOAT
    EXTERNAL NAME 'getStaticNumber(double, double, double) return double')
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    After that I tried some SQL commands:
    create table pointsj of point3dj;
    insert into pointsj values (point3dj(2,1,1));
    SELECT x, a.getnumber() FROM pointsj a;Now, the problem:
    Everything works fine, if I delete the constructor
    public Point3dj(double x, double y, double z)
    this.x = x;
    this.y = y;
    this.z = z;
    in the java class, or if I replace it with a constructor that has no input arguments.
    But with this few code lines in the java file, I get an error when executing the SQL command
    SELECT x, a.getnumber() FROM pointsj a;The Error is:
    "ORA-00932: inconsistent data types: an IN argument at position 1 that is an instance of an Oracle type convertible to an instance of a user defined Java class expected, an Oracle type that could not be converted to a java class received"
    I think, there are some problems with the input argument of the constructor, but why? I don't need the constructor in SQL, but it is used by a routine of another java class, so I can't just delete it.
    Can anybody help me? I would be very glad about that since I already tried a lot and also search in forums and so on, but wasn't successful up to new.
    Thanks!

    Dear Avi,
    This makes sense when it is a short code sample (and i think i've done that across various posts), but sometime this is too long to copy/paste, in these cases, i refer to the freely available code samples, as i did above on this forum; here is the quote.
    Look at examples of VARRAY and Nested TABLES of scalar types in the code samples of my book (chapter 8) http://books.elsevier.com/us//digitalpress/us/subindex.asp?maintarget=companions/defaultindividual.asp&isbn=9781555583293&country=United+States&srccode=&ref=&subcode=&head=&pdf=&basiccode=&txtSearch=&SearchField=&operator=&order=&community=digitalpress
    As you can see, i was not even asking people to buy the book, just telling them where to grab the code samples.
    I appreciate your input on this and as always, your contribution to the forum, Kuassi

  • Problem with a Constructor of a backingBean

    Hello there!, i have a problem with this code , on a constructor of backingBean
        public Login() {
            System.out.println("New instance!!");
            FacesContext fc = FacesContext.getCurrentInstance();
            String sessionId = fc.getExternalContext().getRequestParameterMap().get("id");
            System.out.println("Session ID :" + sessionId);
            if(sessionId.equals("1"){
            UIComponent it2 = (UIComponent)fc.getViewRoot().findComponent("it2");
            it2.getAttributes().put("value", "Hello World");
        }The error :
    <30-12-2009 06:12:10 PM BOT> <Error> <HTTP> <BEA-101020>
    <[ServletContext@17783620[app:LoginJSF module:LoginJSF-ViewController-context-root path:/LoginJSF-ViewController-context-root spec-version:2.5]]
    Servlet failed with Exception oracle.mds.exception.MDSRuntimeException: MDS-00168:
    Any help?

    hi Frank
    See forum thread "JDeveloper 11g Handbook : Chapter 10 : MDSRuntimeException MDS-00168" about a (possibly related) MDSRuntimeException (MDS-00168) with a reproducible scenario.
    regards
    Jan Vervecken

  • Problem with threads running javaw

    Hi,
    Having a problem with multi thread programming using client server sockets. The program works find when starting the the application in a console using java muti.java , but when using javaw multi.java the program doesnt die and have to kill it in the task manager. The program doesnt display any of my gui error messages either when the server disconnect the client. all works find in a console. any advice on this as I havent been able to understand why this is happening? any comment would be appreciated.
    troy.

    troy,
    Try and post a minimum code sample of your app which
    does not work.
    When using javaw, make sure you redirect the standard
    error and standard output streams to file.
    Graeme.Hi Graeme,
    I dont understand what you mean by redirection to file? some of my code below.
    The code works fine under a console, code is supposed to exit when the client (the other server )disconnects. the problem is that but the clientworker side of the code still works. which under console it doesnt.
    public class Server{
    ServerSocket aServerSocket;
    Socket dianosticsSocket;
    Socket nPortExpress;
    ClientListener aClientListener;
    LinkedList queue = new LinkedList();
    int port = 0;
    int clientPort = 0;
    String clientName = null;
    boolean serverAlive = true;
    * Server constructor generates a server
    * Socket and then starts a client threads.
    * @param aPort      socket port of local machine.
    public Server(int aPort, String aClientName, int aClientPort){
    port = aPort;
    clientName = aClientName;
    clientPort = aClientPort;
    try{
    // create a new thread
    aServerSocket = new ServerSocket(port) ;
    // connect to the nPortExpress
    aClientListener = new ClientListener(InetAddress.getByName(clientName), clientPort, queue,this);
    // aClientListener.setDaemon(true);
    aClientListener.start();
    // start a dianostic port
    DiagnosticsServer aDiagnosticsServer = new DiagnosticsServer(port,queue,aClientListener);
    // System.out.println("Server is running on port " + port + "...");
    // System.out.println("Connect to nPort");
    catch(Exception e)
    // System.out.println("ERROR: Server port " + port + " not available");
    JOptionPane.showMessageDialog(null, (e.toString()),"ERROR: Server port " + port + " not available", JOptionPane.ERROR_MESSAGE);
    serverAlive = false;
    System.exit(1);
    while(serverAlive&&aClientListener.hostSocket.isConnected()){
    try{
    // connect the client
    Socket aClient = aServerSocket.accept();
    //System.out.println("open client connection");
    //System.out.println("client local: "+ aClient.getLocalAddress().toString());
    // System.out.println("client localport: "+ aClient.getLocalPort());
    // System.out.println("client : "+ aClient.getInetAddress().toString());
    // System.out.println("client port: "+ aClient.getLocalPort());
    // make a new client thread
    ClientWorker clientThread = new ClientWorker(aClient, queue, aClientListener, false);
    // start thread
    clientThread.start();
    catch(Exception e)
    //System.out.println("ERROR: Client connection failure");
    JOptionPane.showMessageDialog(null, (e.toString()),"ERROR: Client connection failure", JOptionPane.ERROR_MESSAGE);
    }// end while
    } // end constructor Server
    void serverExit(){
         JOptionPane.showMessageDialog(null, "Server ","ERROR: nPort Failure", JOptionPane.ERROR_MESSAGE);
         System.exit(1);
    }// end class Server
    *** connect to another server
    public class ClientListener extends Thread{
    InetAddress hostName;
    int hostPort;
    Socket hostSocket;
    BufferedReader in;
    PrintWriter out;
    boolean loggedIn;
    LinkedList queue;      // reference to Server queue
    Server serverRef; // reference to main server
    * ClientListener connects to the host server.
    * @param aHostName is the name of the host eg server name or IP address.
    * @param aHostPort is a port number of the host.
    * @param aLoginName is the users login name.
    public ClientListener(InetAddress aHostName, int aHostPort,LinkedList aQueue,Server aServer)      // reference to Server queue)
    hostName = aHostName;
    hostPort = aHostPort;
    queue = aQueue;
    serverRef = aServer;      
    // connect to the server
    try{
    hostSocket = new Socket(hostName, hostPort);
    catch(IOException e){
    //System.out.println("ERROR: Connection Host Failed");
    JOptionPane.showMessageDialog(null, (e.toString()),"ERROR: Connection to nPort Failed", JOptionPane.ERROR_MESSAGE);     
    System.exit(0);
    } // end constructor ClientListener
    ** multi client connection server
    ClientWorker(Socket aSocket,LinkedList aQueue, ClientListener aClientListener, boolean diagnostics){
    queue = aQueue;
    addToQueue(this);
    client = aSocket;
    clientRef = aClientListener;
    aDiagnostic = diagnostics;
    } // end constructor ClientWorker
    * run method is the main loop of the server program
    * in change of handle new client connection as well
    * as handle all messages and errors.
    public void run(){
    boolean alive = true;
    String aSubString = "";
    in = null;
    out = null;
    loginName = "";
    loggedIn = false;
    while (alive && client.isConnected()&& clientRef.hostSocket.isConnected()){
    try{
    in = new BufferedReader(new InputStreamReader(client.getInputStream()));
    out = new PrintWriter(new OutputStreamWriter(client.getOutputStream()));
    if(aDiagnostic){
    out.println("WELCOME to diagnostics");
    broadCastDia("Connect : diagnostics "+client.getInetAddress().toString());
    out.flush();
    else {       
    out.println("WELCOME to Troy's Server");
    broadCastDia("Connect : client "+client.getInetAddress().toString());
         out.flush();
    String line;
    while(((line = in.readLine())!= null)){
    StringTokenizer aStringToken = new StringTokenizer(line, " ");
    if(!aDiagnostic){
    broadCastDia(line);
    clientRef.sendMessage(line); // send mesage out to netExpress
    out.println(line);
    out.flush();
    else{
    if(line.equals("GETIPS"))
    getIPs();
    else{
    clientRef.sendMessage(line); // send mesage out to netExpress
    out.println(line);
    out.flush();
    } // end while
    catch(Exception e){
    // System.out.println("ERROR:Client Connection reset");
                             JOptionPane.showMessageDialog(null, (e.toString()),"ERROR:Client Connection reset", JOptionPane.ERROR_MESSAGE);     
    try{
    if(aDiagnostic){
    broadCastDia("Disconnect : diagnostics "+client.getInetAddress().toString());
    out.flush();
    else {       
    broadCastDia("Disconnect : client "+client.getInetAddress().toString());
         out.flush();
    // close the buffers and connection;
    in.close();
    out.close();
    client.close();
    // System.out.println("out");
    // remove from list
    removeThreadQueue(this);
    alive = false;
    catch(Exception e){
    // System.out.println("ERROR: Client Connection reset failure");
    JOptionPane.showMessageDialog(null, (e.toString()),"ERROR: Client Connection reset failure", JOptionPane.ERROR_MESSAGE);     
    }// end while
    } // end method run
    * method run - Generates io stream for communicating with the server and
    * starts the client gui. Run also parses the input commands from the server.
    public void run(){
    boolean alive = true;
    try{
    // begin to life the gui
    // aGuiClient = new ClientGui(hostName.getHostName(), hostPort, loginName, this);
    // aGuiClient.show();
    in = new BufferedReader(new InputStreamReader(hostSocket.getInputStream()));
    out = new PrintWriter(new OutputStreamWriter(hostSocket.getOutputStream()));
    while (alive && hostSocket.isConnected()){
    String line;
    while(((line = in.readLine())!= null)){
    System.out.println(line);
    broadCast(line);
    } // end while
    } // end while
    catch(Exception e){
    //     System.out.println("ERRORa Connection to host reset");
    JOptionPane.showMessageDialog(null, (e.toString()),"ERROR: Connection to nPort reset", JOptionPane.ERROR_MESSAGE);
    try{
    hostSocket.close();
         }catch(Exception a){
         JOptionPane.showMessageDialog(null, (a.toString()),"ERROR: Exception", JOptionPane.ERROR_MESSAGE);
    alive = false;
    System.exit(1);
    } // end method run

  • Hyperion planning installation(Problem with application server deployment)

    Hi There:
    I am new to hyperion planning.I am trying to install planning.I got problem with Hyperion Configuration utility while configuring application server deployment.Its show message failed.Please guide me how to fix this.If it is possible can you please send me any personal documentation on installation.I am trying this for past 4 day's.Below is the error its showing in configtool
         ... 10 more
    (Mar 09, 2008, 08:26:04 PM), com.hyperion.cis.config.wizard.ProductTaskSelectionPanel, INFO, Validating dependencies...
    (Mar 09, 2008, 08:26:04 PM), com.hyperion.cis.config.wizard.ProductTaskSelectionPanel$5, DEBUG, Product: Planning; Dependencies: []
    (Mar 09, 2008, 08:26:04 PM), com.hyperion.cis.config.wizard.ProductTaskSelectionPanel, DEBUG, task to execute: HspDBPropertyLocation
    (Mar 09, 2008, 08:26:04 PM), com.hyperion.cis.config.wizard.ProductTaskSelectionPanel, DEBUG, task to execute: applicationServerDeployment
    (Mar 09, 2008, 08:26:04 PM), com.hyperion.cis.config.wizard.PanelEventDispatcher, DEBUG, constructor
    (Mar 09, 2008, 08:26:04 PM), com.hyperion.cis.config.wizard.AppServerSelectionPanel, INFO, AppServerSelectionPanel in queryEnter
    (Mar 09, 2008, 08:26:04 PM), com.hyperion.cis.config.wizard.AppServerSelectionPanel, INFO, Server: WebLogic 8.1; deployment type = both
    (Mar 09, 2008, 08:26:04 PM), com.hyperion.cis.config.wizard.AppServerSelectionPanel, INFO, Server: WebSphere 5.1; deployment type = both
    (Mar 09, 2008, 08:26:04 PM), com.hyperion.cis.config.wizard.AppServerSelectionPanel, INFO, Server: Tomcat 5.0.28; deployment type = both
    (Mar 09, 2008, 08:26:08 PM), com.hyperion.cis.config.wizard.AppServerSelectionPanel, INFO, AppServerSelectionPanel in queryExit
    (Mar 09, 2008, 08:26:08 PM), com.hyperion.cis.config.wizard.AppServerSelectionPanel, DEBUG, AppServer selected: WebLogic 8.1
    (Mar 09, 2008, 08:26:08 PM), com.hyperion.cis.config.wizard.ProductCustomInputPanel, ERROR, Error:
    java.lang.NullPointerException
         at com.hyperion.cis.config.wizard.ProductCustomInputPanel.queryEnter(ProductCustomInputPanel.java:88)
         at com.installshield.wizard.awt.AWTWizardUI.currentBeanChanged(Unknown Source)
         at com.installshield.wizard.swing.SwingWizardUI.currentBeanChanged(Unknown Source)
         at com.installshield.wizard.StandardWizardListener.currentBeanChanged(Unknown Source)
         at com.installshield.wizard.Wizard$RunThread.run(Unknown Source)
    (Mar 09, 2008, 08:26:09 PM), com.hyperion.cis.config.AppServerDeployer, DEBUG, Starting WebLogic 8.1 deployment...
    (Mar 09, 2008, 08:26:09 PM), com.hyperion.cis.config.AppServerDeployer, DEBUG, pre-Deploy: Planning
    (Mar 09, 2008, 08:26:09 PM), com.hyperion.cis.config.AppServerDeployer, DEBUG, Deploy: Planning
    (Mar 09, 2008, 08:26:09 PM), com.hyperion.cis.config.wizard.RunAllTasksWizardAction, ERROR, Error:
    java.lang.NullPointerException
         at com.hyperion.cis.config.AppServerDeployer.initContexts(AppServerDeployer.java:628)
         at com.hyperion.cis.config.AppServerDeployer.deploy(AppServerDeployer.java:548)
         at com.hyperion.cis.config.AppServerDeployer.deploy(AppServerDeployer.java:526)
         at com.hyperion.cis.config.wizard.RunAllTasksWizardAction.executeDeployerTask(RunAllTasksWizardAction.java:251)
         at com.hyperion.cis.config.wizard.RunAllTasksWizardAction.execute(RunAllTasksWizardAction.java:156)
         at com.installshield.wizard.RunnableWizardBeanContext.run(Unknown Source)
    (Mar 09, 2008, 08:26:13 PM), com.hyperion.cis.config.wizard.CustomSummaryPanel, DEBUG, CustomSummaryPanel in queryExit
    Please help me.Email id:[email protected]
    Thanks
    Harsha.
    Message was edited by:
    user603943

    I think the installation of planning on Vista is difficult. As some of the files doesn't support even i am tired of doing that.
    But tell me one thing have you installed all other products , I mean Essbase, (server, client) , AAS and Shared services.
    Are they working good .
    I have formatted my system to XP and installed everything , but the problem is when i install planning it prompts me that IIS 5 should be greater other wise EPM will not install...
    there are lot of things with planning 1) i can't datasource as it is not highlighting when we configure with Shared services
    2) It does not create product instance .
    If any one can fix this thing by giving me a suggestions.
    Advance Thanks

  • Advance level drawing problem with Jframe and JPanel need optimize sol?

    Dear Experts,
    I m trying to create a GUI for puzzle game following some kind of "game GUI template", but i have problems in that,so i tried to implement that in various ways after looking on internet and discussions about drawing gui in swing, but i have problem with both of these, may be i m doing some silly mistake, which is still out of my consideration. please have a look at these two and recommend me one of them, which is running without problems (flickring and when you enlarge window the board draw copies (tiled) everywhere,
    Note: i don't want to inherit jpanel or Jframe
    here is my code : import java.awt.BorderLayout;
    public class GameMain extends JFrame {
         private static final long serialVersionUID = 1L;
         public int mX, mY;
         int localpoints = 0;
         protected static JTextField[][] squares;
         protected JLabel statusLabel = new JLabel("jugno");
         Label lbl_score = new Label("score");
         Label lbl_scorelocal = new Label("local score");
         protected static TTTService remoteTTTBoard;
         // Define constants for the game
         static final int CANVAS_WIDTH = 800; // width and height of the game screen
         static final int CANVAS_HEIGHT = 600;
         static final int UPDATE_RATE = 4; // number of game update per second
         static State state; // current state of the game
         private int mState;
         // Handle for the custom drawing panel
         private GameCanvas canvas;
         // Constructor to initialize the UI components and game objects
         public GameMain() {
              // Initialize the game objects
              gameInit();
              // UI components
              canvas = new GameCanvas();
              canvas.setPreferredSize(new Dimension(CANVAS_WIDTH, CANVAS_HEIGHT));
              this.setContentPane(canvas);
              this.setDefaultCloseOperation(EXIT_ON_CLOSE);
              this.pack();
              this.setTitle("MY GAME");
              this.setVisible(true);
         public void gameInit() {     
         // Shutdown the game, clean up code that runs only once.
         public void gameShutdown() {
         // To start and re-start the game.
         public void gameStart() {
         private void gameLoop() {
         public void keyPressed(KeyEvent e) {
         public void keyTyped(KeyEvent e) {
         public void gameKeyReleased(KeyEvent e) {
              PuzzleBoard bd = getBoard();
              for (int row = 0; row < 4; ++row) {
                   for (int col = 0; col < 4; ++col) {
                        if (e.getSource() == squares[row][col]) {
                             if (bd.isOpen(col, row)) {
                                  lbl_score.setText("Highest Score = "
                                            + Integer.toString(bd.getPoints()));
                                  setStatus1(bd);
                                  pickSquare1(col, row, squares[row][col].getText()
                                            .charAt(0));
         protected void pickSquare1(int col, int row, char c) {
              try {
                   remoteTTTBoard.pick(col, row, c);
              } catch (RemoteException e) {
                   System.out.println("Exception: " + e.getMessage());
                   e.printStackTrace();
                   System.exit(1);
         // method "called" by remote object to update the state of the game
         public void updateBoard(PuzzleBoard new_board) throws RemoteException {
              String s1;
              for (int row = 0; row < 4; ++row) {
                   for (int col = 0; col < 4; ++col) {
                        squares[row][col].setText(new_board.ownerStr(col, row));
              lbl_score.setText("Highest Score = "
                        + Integer.toString(new_board.getPoints()));
              setStatus1(new_board);
         protected void setStatus1(PuzzleBoard bd) {
              boolean locals = bd.getHave_winner();
              System.out.println("local win" + locals);
              if (locals == true) {
                   localpoints++;
                   System.out.println("in condition " + locals);
                   lbl_scorelocal.setText("Your Score = " + localpoints);
              lbl_score
                        .setText("Highest Score = " + Integer.toString(bd.getPoints()));
         protected PuzzleBoard getBoard() {
              PuzzleBoard res = null;
              try {
                   res = remoteTTTBoard.getState();
              } catch (RemoteException e) {
                   System.out.println("Exception: " + e.getMessage());
                   e.printStackTrace();
                   System.exit(1);
              return res;
         /** Custom drawing panel (designed as an inner class). */
         class GameCanvas extends JPanel implements KeyListener {
              /** Custom drawing codes */
              @Override
              public void paintComponent(Graphics g) {
                   // setOpaque(false);
                   super.paintComponent(g);
                   // main box; everything placed in this
                   // JPanel box = new JPanel();
                   setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
                   // add(statusLabel, BorderLayout.NORTH);
                   // set up the x's and o's
                   JPanel xs_and_os = new JPanel();
                   xs_and_os.setLayout(new GridLayout(5, 5, 0, 0));
                   squares = new JTextField[5][5];
                   for (int row = 0; row < 5; ++row) {
                        for (int col = 0; col < 5; ++col) {
                             squares[row][col] = new JTextField(1);
                             squares[row][col].addKeyListener(this);
                             if ((row == 0 && col == 1) || (row == 2 && col == 3)
                             || (row == 1 && col == 4) || (row == 4 && col == 4)
                                       || (row == 4 && col == 0))
                                  JPanel p = new JPanel(new BorderLayout());
                                  JLabel label;
                                  if (row == 0 && col == 1) {
                                       label = new JLabel("1");
                                       label.setHorizontalAlignment(JLabel.LEFT);
                                       label.setVerticalAlignment(JLabel.TOP);
                                  else if (row == 4 && col == 0) {// for two numbers or
                                       // two
                                       // blank box in on row
                                       label = new JLabel("2");
                                       label.setHorizontalAlignment(JLabel.LEFT);
                                       label.setVerticalAlignment(JLabel.TOP);
                                  else if (row == 1 && col == 4) {
                                       label = new JLabel("3");
                                       label.setHorizontalAlignment(JLabel.LEFT);
                                       label.setVerticalAlignment(JLabel.TOP);
                                  else if (row == 4) {
                                       label = new JLabel("4");
                                       label.setHorizontalAlignment(JLabel.LEFT);
                                       label.setVerticalAlignment(JLabel.TOP);
                                  else {
                                       label = new JLabel("5");
                                       label.setHorizontalAlignment(JLabel.LEFT);
                                       label.setVerticalAlignment(JLabel.TOP);
                                  label.setOpaque(true);
                                  label.setBackground(squares[row][col].getBackground());
                                  label.setPreferredSize(new Dimension(label
                                            .getPreferredSize().width, squares[row][col]
                                            .getPreferredSize().height));
                                  p.setBorder(squares[row][col].getBorder());
                                  squares[row][col].setBorder(null);
                                  p.add(label, BorderLayout.WEST);
                                  p.add(squares[row][col], BorderLayout.CENTER);
                                  xs_and_os.add(p);
                             } else if ((row == 2 && col == 1) || (row == 1 && col == 2)
                                       || (row == 3 && col == 3) || (row == 0 && col == 3)) {
                                  xs_and_os.add(squares[row][col]);
                                  // board[ row ][ col ].setEditable(false);
                                  // board[ row ][ col ].setText("");
                                  squares[row][col].setBackground(Color.RED);
                                  squares[row][col].addKeyListener(this);
                             } else {
                                  squares[row][col] = new JTextField(1);
                                  // squares[row][col].addActionListener(this);
                                  squares[row][col].addKeyListener(this);
                                  xs_and_os.add(squares[row][col]);
                   this.add(xs_and_os);
                   this.add(statusLabel);
                   this.add(lbl_score);
                   this.add(lbl_scorelocal);
              public void keyPressed(KeyEvent e) {
              public void keyReleased(KeyEvent e) {
                   gameKeyReleased(e);
              public void keyTyped(KeyEvent e) {
         // main
         public static void main(String[] args) {
              SwingUtilities.invokeLater(new Runnable() {
                   @Override
                   public void run() {
                        new GameMain();
      thanks a lot for your time , consideration and efforts.
    jibby
    Edited by: jibbylala on Sep 20, 2010 6:06 PM

    jibbylala wrote:
    thanks for mentioning as i wasn't able to write complete context here.Yep thanks camickr. I think that Darryl's succinct reply applies here as well.

  • Problem with JTable and JPanel

    Hi,
    I'm having problems with a JTable in a JPanel. The code is basicly as follows:
    public class mainFrame extends JFrame
            public mainFrame()
                    //A menu is implemeted giving rise to the following actions:
                    public void actionPerformed(ActionEvent evt)
                            String arg = evt.getActionCommand();
                            if(arg.equals("Sit1"))
                            //cells, columnNames are initiated correctly
                            JTable table = new JTable(cells,columnNames);
                            JPanel holdingPanel = new JPanel();
                            holdingPanel.setLayout( new BorderLayout() );
                            JScrollPane scrollPane = new JScrollPane(holdingPanel);
                            holdingPanel.setBackground(Color.white);
                            holdingPanel.add(table,BorderLayout.CENTER);
                            add(scrollPane, "Center");
                            if(arg.equals("Sit2"))
                                    if(scrollPane !=null)
                                            remove(scrollPane);validate();System.out.println("ScrollPane");
                                    if(holdingPanel !=null)
                                            remove(holdingPanel);
                                    if(table !=null)
                                            remove(table);table.setVisible(false);System.out.println("table");
                            //Put other things on the holdingPanel....
            private JScrollPane scrollPane;
            private JPanel holdingPanel;
            private JTable table;
    }The problem is that the table isn't removed. When you choose another situation ( say Sit2), at first the table apparently is gone, but when you press with the mouse in the area it appeared earlier, it appears again. How do I succesfully remove the table from the panel? Removing the panel doesn't seem to be enough. Help is much appreciated...
    Best regards
    Schwartz

    If you reuse the panel and scroll pane throughout the application,
    instantiate them in the constructor, not in an often-called event
    handler. In the event handler, you only do add/remove of the table
    on to the panel. You can't remove the table from the container
    which does not directly contain it.
    if (arg.equals("Sit2")){
      holdingPanel.remove(table);
      holdingPanel.revalidate();
      holdingPanel.repaint(); //sometimes necessary
    }

  • Problem with PropertyChangeListener and JTextField

    I'm having a problem with PropertyChangeListener and JTextField.
    I can not seem to get the propertychange event to fire.
    Anyone have any idea why the code below doesn't work?
    * NewJFrame.java
    * Created on May 15, 2005, 4:21 PM
    import java.beans.*;
    import javax.swing.*;
    * @author wolfgray
    public class NewJFrame extends javax.swing.JFrame
    implements PropertyChangeListener {
    /** Creates new form NewJFrame */
    public NewJFrame() {
    initComponents();
    jTextField1.addPropertyChangeListener( this );
    public void propertyChange(PropertyChangeEvent e) {
    System.out.println(e);
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    private void initComponents() {
    jTextField1 = new javax.swing.JTextField();
    jScrollPane1 = new javax.swing.JScrollPane();
    jFormattedTextField1 = new javax.swing.JFormattedTextField();
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    jTextField1.setText("jTextField1");
    getContentPane().add(jTextField1, java.awt.BorderLayout.NORTH);
    jFormattedTextField1.setText("jFormattedTextField1");
    jScrollPane1.setViewportView(jFormattedTextField1);
    getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
    pack();
    * @param args the command line arguments
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new NewJFrame().setVisible(true);
    // Variables declaration - do not modify
    private javax.swing.JFormattedTextField jFormattedTextField1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField jTextField1;
    // End of variables declaration
    }

    If you want to listen to changes in the textfield's contents you should use a DocumentListener and not a PropertyChangeListener:
    http://java.sun.com/docs/books/tutorial/uiswing/events/documentlistener.html
    And please use [co[/i]de]  tags when you are posting code (press the code button above the message window).

  • Events problem with (Java and ActiveX)

    Hi,
    I use an ActiveX component with Java and i've got a problem with events.
    Java classes were generated with Bridge2Java (IBM).
    In order to manage events I added a listener in my application :
         javaMyActiveX = new MyActiveX();
         javaMyActiveX.add_DMyActiveXEventsListener(new _DMyActiveXEventsAdapter());
    I also added a constructor in the _DMyActiveXEventsAdapter class and I fill the body of methods.
    The ActiveX generates two types of events :
    - The ones are directly generated by methods.
    - The others are generated by a thread.
    With MS Products (VB, Visual C++, Visual J++), I catch all events.
    With java (jdk 1.4), I catch only events generated by methods.
    Can anyone help me.

    I'm not 100% sure, but the last time I used that bridge, it only worked if you ran your Java app within a Microsoft VM.

  • Problem with JFrame class.

    To risolve my problem i need for few diferent frame
    ( for esample in one i put JTextFild that take the user input, in a nother one i need for program output ) . But, th problem is, all my frames using the same object.
    If i construct diferent JFrame window class i have problem that i don't acess in the same object from all the window. And if i dont use a object, i have static acess .
    I risolve the problem with 1 JFrame class with diferent constructors, but i wont a diferent way to risolve my problem, because there are few windows.
    Help me.....

    Make the class that extends JFrame an inner class of the the main class. You can then access all members of the outer class.

Maybe you are looking for

  • How to put some tabs in sales order item level  invisible mode

    Hello Gurus , Good evening everybody , We have some specific requirement from the client - Client does n't want few  end users to see the price details in sales so they want  the condition tab to be  invisible mode in sales order item lvel only for f

  • My bottom has gone!

    I am a total novice at all this, but. I made my own site www.newhomecyprus.com when the old internet explorer was about. Since the wonderful microsoft update, the bottoms of my pages have ridden up and no longer go to the bottom. Like on this page ht

  • G5 PowerPc vs G5 Intel

    Hi all, this is more of an "asking opinions" thing. With the new G5 Intels coming around the corner. Is there any point in acquiring the current G5 models or the ones before that? I'm just noticing alot of G5s being put up for sale, including the lat

  • HT4623 Ipad not playing any videos on Internet when using wifi

    Ipad 4 not playing any videos when using wifi

  • Add Resource Files

    Can anyone tell me how to add images or audio files, to my java application so I can then access them using this.getClass().getResource(URL); ? I'm using NetBeans 6.7.1 Thanks