Please need help with Inner Classes

Hi! I have the following inner class, but it is not an "explicit" inner class:
import java.util.*;
public class EXTERIOR_NOEXPLICITA {
     private Vector i;
     public void llena_Vector(int a){
          i = new Vector();
          for(int z=0;z<=a;z++)
               i.addElement(""+z);
     public Enumeration test() {
          return new Enumeration(){
               int item = i.size()-1;
               public boolean hasMoreElements(){
                    return(item >= 0);
               public Object nextElement(){
                    if(!hasMoreElements())
                         throw new NoSuchElementException();
                    else
                         return i.elementAt(item--);
My question is, how can I put it in an explicyt inner class?
Plese help me! =)
Raul

I am not entirely sure what you mean by explicit inner class. If you mean converting your anonymous class into a nested class, then it is quite easy:
import java.util.*;
public class EXTERIOR_NOEXPLICITA {
  private Vector i;
  public void llena_Vector(int a) {
    i = new Vector();
    for (int z = 0; z <= a; z++)
      i.addElement("" + z);
  private final class MyEnumeration implements Enumeration {
    int item = i.size() - 1;
    public boolean hasMoreElements() {
      return (item >= 0);
    public Object nextElement() {
      if (!hasMoreElements())
        throw new NoSuchElementException();
      else
        return i.elementAt(item--);
  public Enumeration test() {
    return new MyEnumeration();

Similar Messages

  • Please, need help with a query

    Hi !
    Please need help with this query:
    Needs to show (in cases of more than 1 loan offer) the latest create_date one time.
    Meaning, In cases the USER_ID, LOAN_ID, CREATE_DATE are the same need to show only the latest, Thanks!!!
    select distinct a.id,
    create_date,
    a.loanid,
    a.rate,
    a.pays,
    a.gracetime,
    a.emailtosend,
    d.first_name,
    d.last_name,
    a.user_id
    from CLAL_LOANCALC_DET a,
    loan_Calculator b,
    bv_user_profile c,
    bv_mr_user_profile d
    where b.loanid = a.loanid
    and c.NET_USER_NO = a.resp_id
    and d.user_id = c.user_id
    and a.is_partner is null
    and a.create_date between
    TO_DATE('6/3/2008 01:00:00', 'DD/MM/YY HH24:MI:SS') and
    TO_DATE('27/3/2008 23:59:00', 'DD/MM/YY HH24:MI:SS')
    order by a.create_date

    Take a look on the syntax :
    max(...) keep (dense_rank last order by ...)
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions056.htm#i1000901
    Nicolas.

  • Please need help with this query

    Hi !
    Please need help with this query:
    Needs to show (in cases of more than 1 loan offer) the latest create_date one time.
    Meaning, In cases the USER_ID, LOAN_ID, CREATE_DATE are the same need to show only the latest, Thanks!!!
    select distinct a.id,
    create_date,
    a.loanid,
    a.rate,
    a.pays,
    a.gracetime,
    a.emailtosend,
    d.first_name,
    d.last_name,
    a.user_id
    from CLAL_LOANCALC_DET a,
    loan_Calculator b,
    bv_user_profile c,
    bv_mr_user_profile d
    where b.loanid = a.loanid
    and c.NET_USER_NO = a.resp_id
    and d.user_id = c.user_id
    and a.is_partner is null
    and a.create_date between
    TO_DATE('6/3/2008 01:00:00', 'DD/MM/YY HH24:MI:SS') and
    TO_DATE('27/3/2008 23:59:00', 'DD/MM/YY HH24:MI:SS')
    order by a.create_date

    Perhaps something like this...
    select id, create_date, loanid, rate, pays, gracetime, emailtosend, first_name, last_name, user_id
    from (
          select distinct a.id,
                          create_date,
                          a.loanid,
                          a.rate,
                          a.pays,
                          a.gracetime,
                          a.emailtosend,
                          d.first_name,
                          d.last_name,
                          a.user_id,
                          max(create_date) over (partition by a.user_id, a.loadid) as max_create_date
          from CLAL_LOANCALC_DET a,
               loan_Calculator b,
               bv_user_profile c,
               bv_mr_user_profile d
          where b.loanid = a.loanid
          and   c.NET_USER_NO = a.resp_id
          and   d.user_id = c.user_id
          and   a.is_partner is null
          and   a.create_date between
                TO_DATE('6/3/2008 01:00:00', 'DD/MM/YY HH24:MI:SS') and
                TO_DATE('27/3/2008 23:59:00', 'DD/MM/YY HH24:MI:SS')
    where create_date = max_create_date
    order by create_date

  • Need help with a Class.

    Ok hey guys i got A project for school and i need help. I asked my teacher and he num so yea. here it is
    this is my blog class
    /* Project Name: .java
                 Name:
                Class: Programing 2 #0047-02 Pds 5&6
      Variable List:
                   Info:
    import java.util.Scanner;
    import java.util.Date;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    public class blog
         String date2;
         String user;
         String Entry;
         public void GetInfo(String Iuser,String IEntry)
              DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
              Date date = new Date();
              date2 = dateFormat.format(date);
              user = Iuser;
              Entry = IEntry:
         public void ShowInfo()
              System.out.println(date2 + " " + user + " Said: " + Entry);
    }This is my test class
    /* Project Name: .java
                 Name: Josh
                Class: Programing 2 #0047-02 Pds 5&6
      Variable List:
                   Info:
    import java.util.Scanner;
    public class test
         String user;
         String Entry;
         public static void main (String[] args)
         {     System.out.println("Welcome Please Eneter UserName");
              Scanner kb = new Scanner(System.in);
              user = kb.next();
              System.out.println("Please Enter Your Entry");
              Entry = kb.next();
              blog info = new blog();
              blog.GetInfo(user,Entry);
              blog.ShowInfo();
    }So what is sopost to do in the test it ask user to import user name and entery. It send it to blog Class, then it send it out. Here is my errors
    G:\VOC T2\Java\Chap4\test.java:21: non-static variable user cannot be referenced from a static context
              user = kb.next();
              ^
    G:\VOC T2\Java\Chap4\test.java:25: non-static variable Entry cannot be referenced from a static context
              Entry = kb.next();
              ^
    G:\VOC T2\Java\Chap4\test.java:29: non-static variable user cannot be referenced from a static context
              blog.GetInfo(user,Entry);
                           ^
    G:\VOC T2\Java\Chap4\test.java:29: non-static variable Entry cannot be referenced from a static context
              blog.GetInfo(user,Entry);
                                ^
    G:\VOC T2\Java\Chap4\test.java:29: GetInfo(java.lang.String,java.lang.String,java.lang.String) in blog cannot be applied to (java.lang.String,java.lang.String)
              blog.GetInfo(user,Entry);
                  ^
    G:\VOC T2\Java\Chap4\test.java:31: non-static method ShowInfo() cannot be referenced from a static context
              blog.ShowInfo();
                  ^
    6 errors
    Tool completed with exit code 1 Plez help

    -- "non-static X cannot be referenced from a static context" --
    You get this error because static members don't require an instance of the object to be accessed; they belong to the class. But a non-static member belongs to an instance (an individual object). There's no way for the static method to know which instance's variable to use or method to call, and thus, the compiler happily tells you that you can't access an instance member (non-static) from a class context (static).
    [The Java? Tutorial - Understanding Instance and Class Members|http://java.sun.com/docs/books/tutorial/java/javaOO/classvars.html]
    ~

  • Need Help in Inner Classes

    Hi
    I joined as a faculty last week in an institution. To take class I need some information about inner classes in java.
    Basically i need where we use this concept in real time application. Now it is used by the developer or not? Moreover how it is working in java?
    Please somebody help me out...
    thanks in advance
    Chithrakumar

    I once wrote the following example class showing a bit of inner classes"public class Star {
         private String name;
         public Star(String name) { this.name= name; }
         public class Planet {
              private String name;
              public Planet(String name) { this.name= name; }
              public class Moon {
                   private String name;
                   public Moon(String name) { this.name= name; }
                   public String toString() { return name+" (orbiting "+Planet.this+")"; }
              public String toString() { return name+" (orbiting "+Star.this+")"; }
         public String toString() { return name; }
         public static void main(String[] args) {
              System.out.println(new Star("sun").new Planet("earth").new Moon("moon"));
    }Study it, run it and see if you understand what this is all about.
    kind regards,
    Jos

  • Need Help with new Classes / methods

    Hi, I need to create a class called Proposition. It include a Proposition object with 3 variables
    Name, Description, Value
    This is the constructor I wrote:
    private String name;
    private String description;
    private boolean value;
    public Proposition(){
              name = "name";
              description = "description";
              value = false;
    }Now I need a method that give values to the 3 variables in the proposition object:
         public Proposition setProp(String line){
              StringTokenizer ST1 = new StringTokenizer(line, ".");
              String ValidLine = ST1.nextToken()+".";
              StringTokenizer ST2 = new StringTokenizer(ValidLine, "=");
              name = CutSpace(ST2.nextToken());
              description = (ST2.nextToken()).trim();
              value = false;
              return name;
              return description;
              return value;
         }An example of String line is: v = we are in Vancouver.
    When I run the program, I got error message with the 3 return statements saying found String/Boolean while Proposition is needed. I'm not quite sure how to write the return statements. Can any1 help?
    Thx!

    Your setProp() method should not be returning anything. After all it is setting not getting. So just declare it as
    public void setProp(String line){and remove the return statements.

  • Need help with JComponent class

    Hi,
    I'm trying to create a class that has all the characteristics of several GUI components such as JButton, JLabel, JRadioButton .... combined into one big class. But when I run the codes, the object of this new class is not visible on a frame like a JButton or a JLabel would be. Someone, please give me some hints. Thanks.
    The ButtonWrapper class extends JButton and the CheckBoxWrapper class extends JCheckBox and they both work without any problems. The GuiWrapper class (listed below) is the class that has the visibility problem when added to a container of a frame.
    import java.awt.*;
    import javax.swing.*;
    public class GuiWrapper extends JComponent{
      public GuiWrapper(String ptype, String p2, String p3) {
         if(ptype.toLowerCase() == "button"){
           ButtonWrapper b = new ButtonWrapper(p2, p3);
         if(ptype.toLowerCase() == "checkbox"){
           CheckBoxWrapper c = new CheckBoxWrapper(p2, p3);
    }

    Okay, so, for starters, I think this is a Really Bad Idea. If your developers can't handle using the API/tutorial to learn how the components work, your project will fail. This UberClass will not help in the long run. It will also almost certainly turn into a maintainence nightmare for you.
    Of course, since you're going to do it anyway... I suspect your issue lies with paintComponent. If I recall correctly, paintComponent doesn't render anything by default for a JComponent. You'll need to override paintComponent and have it invoke the renderer for the relevant child component.

  • Please need Help with web application deployment in Jdeveloper 12c

    Hi,
    I am desperate for help guys. am trying to deploy a web application in weblogic server, but nothing works!!
    I created a project in jdeveloper and created a jsp page inside the project, all what i want is to run that page!
    I followed the instruction here: Deploying Fusion Web Applications , I don't really know if i did it right or wrong, the document is too detailed and not understood clearly.
    I am a newbie oracle user, and trying to build jsp web application connected to oracle database. application deployment fails it says: cannot run application error deploying IntegratedWeblogic..
    please could you tell me the steps of application deployment in Jdeveloper 12c?
    what deployment profiles I need to create (ear, war , mar)?
    what deployment descriptor I need for my app to work?
    please guys I am newbie to oracle, if you could give me simplified answers and straight instructions it will be appreciated .
    thank you

    hi Timo,
    I am building a local web application, meaning the server is internal and will not connect to the web, only to local pcs via network. the application will insert/select data from the database server. My company wants to embed oracle technology on the datatabse and that what am trying to. I am not that expert in java and oracle in general, my main knowledge are in php, html and mysql programming. through my long internet research a lot has recommended jsp with html to be a good choice.
    At beginning I played around with ADF faces, I found it annoying because I prefer coding than using drag and drop interfaces, which always create unwanted results.
    Also am not that professional java programmer, i started learning jsp and found it easier.
    What I am thinking of is to make a web based application that works in browsers (like php), this application has forms to insert data, and also has forms to output data for printing. that's all. I tried to make it in php, but through my little knowledge and internet researches it seems php does not work with oracle and java is the recommended choice (or it works with php but too complicated to make it)
    any recommendation will be much appreciated
    thank you

  • Need help with a class project

    I'm new to Java and I'm having problems converting a small program to be more functional. Here is my original codeimport java.util.Arrays;
    public class Product
    // initialize arrays
       private int cdNums[] = { 0,0,0,0 };
       private String cdNames[] = { "null", "null", "null", "null" };
       private int cdUnits[] = { 0,0,0,0 };
       private double cdValue[] = { 0.0, 0.0, 0.0, 0.0 };
       private double inventoryValue[] = { 0.0, 0.0, 0.0, 0.0 };
    // initialize instance variable
       private double totalValue = 0;
       private int count;
       public Product( int invNumber[], String albumName[], int invUnits[], double invValue[] )
             cdNums = invNumber;  // store inventory number
             cdNames = albumName;  //store album name
             cdUnits = invUnits;  //store number of units
             cdValue = invValue; // store unit price
       public double calcInventoryValue()
             // calculate Inventory value
                for ( int count = 0; count < cdNums.length; count++ )
                       totalValue =0; // initialize totalValue
                       totalValue =( cdUnits[ count ] * cdValue [ count ] );
               System.out.printf( "%s%d%s%s%s%d%s%.2f%s%.2f\n", "Item #", cdNums[ count ], " is: ", cdNames[ count ], " with ", cdUnits [ count ], " units priced at $", cdValue [ count ], " gives value of $", totalValue );
             return totalValue;
          } // end calcinventoryValue method
    } // end classand the test application: import java.util.Arrays;
    public class ProductTest
       public static void main( String args[] )
            int invNumber [] = { 1,2,3,4 };
            String albumName[] = { "Wish You Were Here", "Abacab", "Animals", "Security" };
            int invUnits[] = { 200, 150, 50, 500 };
            double invValue[] = { 14.99, 9.99, 23.49, 12.99 };
         Product myProduct = new Product (invNumber, albumName, invUnits, invValue );       
            myProduct.calcInventoryValue();
         } // end main
    } // end class ProductTestWhat I want to do is convert it to read in user input instead of static lists. Here is what I have so far:
    import java.util.Arrays;
    public class Product
    // initialize arrays
       private int cdNums[];
       private String cdNames[];
       private int cdUnits[];
       private double cdValue[];
       private double inventoryValue[];
    // initialize instance variable
       private double runValue = 0;
       private double totalValue = 0;
       private int count;
       public Product( int invNumber[], String albumName[], int invUnits[], double invValue[] )
             cdNums = invNumber;  // store inventory number
             cdNames = albumName;  //store album name
             cdUnits = invUnits;  //store number of units
             cdValue = invValue; // store unit price
       public double calcInventoryValue()
             // calculate Inventory value
                totalValue = 0; // Initialize totalValue variable
                for ( int count = 0; count < cdNums.length; count++ )
                       runValue =0; // initialize runValue
                       runValue =( cdUnits[ count ] * cdValue [ count ] );
               System.out.printf( "%s%d%s%s%s%d%s%.2f%s%.2f\n", "Item #", cdNums[ count ], " is: ", cdNames[ count ], " with ", cdUnits [ count ], " units priced at $", cdValue [ count ], " gives value of $", runValue );
                     totalValue = totalValue += runValue;
              calcTotalValue( totalValue );
             return totalValue;
          } // end calcinventoryValue method
        public double calcTotalValue( double totalValue )
             System.out.printf( "%s%.2f\n", "The total value of the inventory is: $", totalValue );
              return totalValue;
           } // end calcTotalValue method
    } // end classand the new test application:
    import java.util.Arrays;
    import java.util.Scanner;
    public class ProductTest
       public static void main( String args[] )
            double totalValue = 0;
          do 
            { //  open dowhile
             int count = 0; // initialize counter
             Scanner input = new Scanner( System.in ); // call scanner to get input
             for ( int count = 0; count > 0; count++ )
               {  // open for loop
                         System.out.printf ( "%s%d%s\n", "Please enter the inventory # of Item ", count, " or 0 to quit: " );  // prompt for inventory number or sentinel value
                          int invNumber[ count ] = input.nextInt();  // get user input of Item Number
                 if ( invNumber[ count ] != 0 )  // check for sentinel
                   {  // open if
                         System.out.printf ( "%s%d\n","Please enter the album name of Item #", invNumber[ count ] );  // prompt for album name
                         String albumName[ count ] = input.nextLine();  // get input album name
                         System.out.printf ( "%s%d\n", "Please enter the number of units in stock for Item #", invNumber[ count ] );  // prompt for number of units in stock
                         int invUnits[ count ] = input.nextint();  // input rate of payment
                         System.out.printf ( "%s%.2f\n", "Please enter the unit price for Item #", invNumber[ count ] );  // prompt for unit price
                         double unitValue = input.nextDouble();  // input rate of payment
                         System.out.println();  // print blank line for readability
                   } // close if
                else
                   {  // open else
                      Product myProduct = new Product (invNumber, albumName, invUnits, invValue );       
                         myProduct.calcInventoryValue();
                   } // close else
               } // close for loop           
           } while ( invNumber != 0 );  // loop back to inputting employee name and close dowhile
        } // end main
    } // end class ProductTestthe compiler is telling me for ProductTest that it is expecting "]" for the following line: int invNumber[ count ] = input.nextInt();Do I need to store the data in a variable first and then feed it into the array? What do I need to do to complete this code?

    OK, yeah. Change the Product constructor so that it takes scalar values (as opposed to arrays) -- a single int for units in stock, and single String for name, etc.
    Then you can create multiple objects of that class, one for each CD or whatever.
    It makes sense to hardcode values in the ProductTest class, but not really in the Product class. Your ProductTest class is almost there. You know how in the main method you create a single Product object with those arrays? Change it so that you have a loop. Loop through the prices, album names, etc., and create a Product for each set of values. Then put the Product objects in an array, or better yet (and if you've covered it in class) into a Collection like a java.util.HashSet or a java.util.ArrayList.
    You said you wanted to make it take values from user input, rather than hardcoded lists. Once you've made the above change, move on to doing that. You can read user input with a java.util.Scanner. Or you can use a java.io.BufferedReader. Did the prof say to use one particular method or another?

  • PLEASE NEED HELP WITH OUTPUTTING HDV/DV!! 16:9 to 4:3!! NEED HELP NOW!

    ok. I started out with HDV footage. Imported that edited it native HD into final cut 5, didn't downconvert. Now I am trying to output the finished work onto a dv camera through firewire. At first i nested the HDV sequence into a NTSC sequence, but the video wouldn't go through to the camera, only audio. I thought it was a connection problem, but then i played some DV footage and it went to the camera fine. So then i exported the DV sequence as a quicktime movie in NTSC form, but that really cropped the 16:9 footage and made it unwatchable. How can i take the 16:9 HDV footage, and letterbox it so that it fits inside a 4:3 frame without cutting off any of the original frame, and then export that to a DV camera? Let me know if you need more info, please help this is due tomorrow!! ahhhhh!

    When you Export using QuickTime Conversion, to DV Stream, you get an option of what the aspect ratio should be. Select 16:9 and the DV stream will be what you're looking for. Opening that in FCP and sending it to the camera should work out well.

  • Need help with inner join and distinct rows

    Hey Guys,
    i have
    1) BaseEnv Table 
    2) Link Table
    3) BaseData Table
    Link table has three columns Id,BaseEnvId,BaseDataId 
    the BaseEnvID is unique in the table where as BaseDataId can be repeated i.e multile rows of BaseEnv Table can point to same BaseData  table row
    Now i want to do  BaseEnvTable inner join Link Table inner join BaseData Table and select 5 columsn ; Name,SyncName,Version,PPO,DOM  from the BaseData table.. the problem is that after i do the inner join I get duplciate records..
    i want to eliminate the duplicate records , can any one help me here

    Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should
    use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 
    This is minimal polite behavior on SQL forums. Now we have to guess and type, guess and type, etc. because of your bad manners. 
    CREATE TABLE Base_Env
    (base_env_id CHAR(10) NOT NULL PRIMARY KEY,
    Think about the name Base_Data; do you have lots of tables without data? Silly, unh? 
    CREATE TABLE Base_Data
    (base_data_id CHAR(10) NOT NULL PRIMARY KEY,
    Your Links table is wrong in concept and implementation. The term “link” refers to a pointer chain structure used in network databases and makes no sense in RDBMS. There is no generic, magic, universal “id” in RDBMS! People that do this are called “id-iots”
    in SQL slang. 
    We can model a particular relationship in a table by referencing the keys in other tables. But we need to know if the relationship is 1:1, 1:m, or n:m. This is the membership of the relationship. Your narrative implies this: 
    CREATE TABLE Links
    (base_env_id CHAR(10) NOT NULL UNIQUE
       REFERENCES Base_Env (base_env_id),
     base_data_id CHAR(10) NOT NULL
       REFERENCES Base_Data (base_data_id));
    >> The base_env_id is unique in the table where as base_data_id can be repeated I.e multiple rows of Base_Env Table can point [sic] to same Base_Data table row. <<
    Again, RDBMS has no pointers! We have referenced an referencing tables. This is a fundamental concept. 
    That narrative you posted has no ON clauses! And the narrative is also wrong. There is no generic “name”, etc. What tables were used in your non-query? Replace the ?? in this skeleton: 
    SELECT ??.something_name, ??.sync_name, ??.something_version, 
           ??.ppo, ??.dom
    FROM Base_Env AS E, Links AS L, Base_Data AS D
    WHERE ?????????;
    >> I want to eliminate the duplicate records [sic], can any one help me here?<<
    Where is the sample data? Where is the results? Please read a book on RDBMS so you can post correct SQL and try again. 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Need help with adding classes

    for the moment ihave to create a program that will add accountants to contracts.
    now from within contract i want to be able to be able to create a contract and then have a method to add an accountant to the contract...could u look at my contract class and c what im doing wrong please and also u can only have one accountant on each contract
    im getting error....cannot find symbol Accountant(Accountant)
    public class Contract
        // instance variables - replace the example below with your own
        private Accountant anAccountant;
        //the number of days
        private double duration;
        private double rateOfContract;
        private static final double vat= 0.21;
        private boolean complete;
        private String type;
        private boolean occupied;
         * Constructor for objects of class Contract
        public Contract(double duration, String type )//Accountant anAccountant, double duration)
            //this.anAccountant = anAccountant;
            this.duration = duration;
            rateOfContract = 0 ;
            complete = false;
            this.type = type;
            occupied = false;
         * a method to get the accountant
       public Accountant getAccountant()
            return anAccountant;
         * a method to get the rate of the contract
        public double getRateOfContract()
            return rateOfContract;
         * a method to check if the contract is complete
        public boolean getComplete()
            return complete;
         * a method to set if the contract to complete
        public void isComplete()
            complete = true ;
         * add an accountant to the contract if his expertise matches
         * the type of contract
        public void addAccountant(Accountant anAccountant)
          if(anAccountant.getExpertise().equals(type))
                if(occupied = false)
                    //add the accountant to the contract
                    anAccountant = Accountant(anAccountant);
                    System.out.println("an accountant has been added to the contract");
                    rateOfContract = anAccountant.getDailyRate() * duration;
                    occupied = true;
                }else{
            }else{
         * a method to check accupied
        public boolean getOccupied()
            return occupied;
    }Message was edited by:
    molleman

    yes off course i have `and i also have a controller class called firm...but i just want the accountant to be added to the contract....and i just cant do it
    public class Accountant
        // instance variables
        protected String name;
        protected String expertise;
        protected double dailyRate;
        protected boolean isActive;
         * Constructor for objects of class Accountant
        public Accountant(String name, String expertise, double dailyRate)
            this.name = name;
            this.expertise = expertise;
            this.dailyRate = dailyRate;
            isActive = false;
         * a method to get the accountants name name
        public String getName()
            return name;
         * a metohd  to get the acvccontats expertise
        public String getExpertise()
            return expertise;
         * a method to get the accountants daily rate
        public double getDailyRate()
            return dailyRate;
         * a method to check if the accountant is active
        public boolean getIsActive()
            return isActive;
         * a method to set the accountant to active or not
        public void setIsActive(boolean active)
            active = isActive;
    }

  • Need help with Runtime class in UNIX

    I am attempting to kick off a C++ executable from within java. This class is called through a UI.
    The executable runs in the form of the exec followed by name=value pairs, ie [path/exec] [n=v] [n=v] ... and runs fine from the command line.
    Examples: These don't kick it off, but don't error either.
    String cmd[] = {"/bin/sh","-c","[path]/[exec] [n=v]};
    String cmd[] = new String[3];
    cmd[0] = "[path]/[exec]";
    cmd[1] = "[n=v]";
    cmd[2] = "[n=v]";
    Process p = Runtime.getRuntime().exec(cmd);
    I'm thinking it may be an environment issue, ie env vars not set because the only way I can get this to work is to put the command in a shell script that sets the env vars and kicks off the executable. Like:
    String cmd[] = {"/bin/sh","-c","/[path]/test.sh"};
    I'd prefer to kick this off from the java code. It sounds like I need to find a way to shell out, run our script to set env vars, then kick off the exec. This is my first attempt w/ using Runtime, so maybe I'm missing something.
    Thanks in advance for the help.

    I think this sort of thing will depend upon the shell you're in. When you use Runtime.exec you (might) lose your "parent" shell's environment variables - this question shows up here now and again, here's one thread that might help:
    http://forum.java.sun.com/thread.jspa?threadID=468648&messageID=2172572
    You might find some enlightenment on Roedy's Java Glossary here: http://mindprod.com/jgloss/exec.html
    Hope that helped
    Lee

  • Need help with generic class with comparable type

    Hi. I'm at University, and I have some coursework to do on writing a generic class which offers ordered binary trees of items which implement the comparable interface.
    I cant get the code to compile which I have written.
    I get the error: OBTComparable.java uses unchecked or unsafe operations
    this is the more detailed information of the error when I compile with -Xlint:unchecked
    OBTComparable.java:62: warning: [unchecked] unchecked call to insert(OBTType) as
    a member of the raw type OBTComparable
    left.insert(insertValue);
    ^
    OBTComparable.java:64: warning: [unchecked] unchecked call to insert(OBTType) as
    a member of the raw type OBTComparable
    right.insert(insertValue);
    ^
    OBTComparable.java:75: warning: [unchecked] unchecked call to find(OBTType) as a
    member of the raw type OBTComparable
    return left.find(findValue);
    ^
    OBTComparable.java:77: warning: [unchecked] unchecked call to find(OBTType) as a
    member of the raw type OBTComparable
    return right.find(findValue);
    ^
    and here is my code for the class
    public class OBTComparable<OBTType extends Comparable<OBTType>>
      // A tree is either empty or not
      private boolean empty;
      // If the tree is not empty then it has
      // a value, a left and a right.
      // These are not used it empty == true
      private OBTType value;
      private OBTComparable left;
      private OBTComparable right;
      // Create an empty tree.
      public OBTComparable()
        setEmpty();
      } // OBTComparable
      // Make this tree into an empty tree.
      private void setEmpty()
        empty = true;
        value = null; // arbitrary
        left = null;
        right = null;
      } // setEmpty
      // See if this is an empty (Sub)tree.
      public boolean isEmpty()
      { return empty; }
      // Get the value which is here.
      public OBTType getValue()
      { return value; }
      // Get the left sub-tree.
      public OBTComparable getLeft()
      { return left; }
      // Get the right sub-tree.
      public OBTComparable getRight()
      { return right; }
      // Store a value at this position in the tree.
      private void setValue(OBTType requiredValue)
        if (empty)
          empty = false;
          left = new OBTComparable<OBTType>(); // Makes a new empty tree.
          right = new OBTComparable<OBTType>(); // Makes a new empty tree.
        } // if
        value = requiredValue;
      } // setValue
      // Insert a value, allowing multiple instances.
      public void insert(OBTType insertValue)
        if (empty)
          setValue(insertValue);
        else if (insertValue.compareTo(value) < 0)
          left.insert(insertValue);
        else
          right.insert(insertValue);
      } // insert
      // Find a value
      public boolean find(OBTType findValue)
        if (empty)
          return false;
        else if (findValue.equals(value))
          return true;
        else if (findValue.compareTo(value) < 0)
          return left.find(findValue);
        else
          return right.find(findValue);
      } // find
    } // OBTComparableI am unsure how to check the types of OBTType I am comparing, I know this is the error. It is the insert method and the find method that are causing it not to compile, as they require comparing one value to another. How to I put the check in the program to see if these two are of the same type so they can be compared?
    If anyone can help me with my problem that would be great!
    Sorry for the long post, I just wanted to put in all the information I know to make it easier for people to answer.
    Thanks in advance
    David

    I have good news and undecided news.
    First the good news. Your code has compiled. Those are warnings not errors. A warning is the compiler's way of saying "I understand what you are asking but maybe you didn't fully think through the consequences and I just thought I would let you know that...[something] "
    In this case it's warning you that you aren't using generics. But like I said this isn't stopping it from compiling.
    The undecided news is the complier is warning you about not using generics. Are you supposed to use generics for this assignment. My gut says no and if that's true then you have no problem. If you are supposed to use generics well then you have some more work.

  • Please need help with Updating photoshop CS6

    I want to update my PS CS6 because it quits unexpectly over and over but when I want to update , the updates goes up to 16,7 % and then update fails.. why and how can  i do it, anybody knows please ??

    Try Restoring Preferences.
    Photoshop Help | Preferences
    If that doesn't clear up the problem, use the CS Cleaner Tools in preparation for a software re-install.
    Use the CC Cleaner Tool to solve installation problems | CC, CS3-CS6
    Nancy O.

Maybe you are looking for

  • In the middle of setting up windows but I don't have the right product key

    Is there a way to exit out of installing windows and get back to the mac screen? I have emailed support and people that I need to contact to get a new product key but it may take a few days and I don't want to leave my Mac with the windows product ke

  • RFC call from a Windows Service

    Hi All, I have created a simple windows service which is making an RFC call to R/3 system. This is not working. Whereas the same piece of code written in a windows application projects(exe) works properly. Does anyone had similer issues working with

  • How to transfer profile information to one domain to other domain

    Hi  Now now i am having one domain(ABC.com) with 700 computer and now my organisation is plan to change our domain name due to some reason. They have some requirement in this migration . They want same profile and files in user desktop when they logg

  • Updating policies and Policy Database or Policy Updates without server restart

    Hi again, I have implemented the flash access reference implementation server including setting up all example database tables (so we have a central database server).  I have started updating policies for the application "whitelist" features and have

  • WRT54GL Cannot get access restrictions to work

    I purchased a WRT54GL router (v1.1 with  firmware 4.30.7) and I cannot for the life of me get the access restrictions to work.  I made three policies, one for my PC with 24/7 access and one for the kids PC with access from 7pm to 9pm during the weekd