Need help for creating class

i m designing a class named Fan to represent a fan. the class contains:
Three constants name slow, medium, and fast with values 1, 2 and 3 to denote the fan speed.
an int data field named speed that specifies the speed of fan(default slow)
an boolean data field named on that specifies whether the fan is on(default false)
a double data field named radius that specifies the radius of the fan(default 5)
a string data field named color that specifies the color of the fan(default blue)
so here is what i want, a method named toString(that returns the fan speed, color and radius in one combined string.if the fan is not on. the method returns fa n color and radius along with string "fan is off" in one combined string.
and a test program creates two fan objects assign maximum speed, radius 10, color yellow, and turn it on to the first object. assign medium speed, radius 5, color blue, and tun it off to the second object.
after i created my two objects this is my output
speed1 is slow, the fan is off, the radius is5.0Blue
speed2 is slow, the fan is off, the radius is5.0Blue
its not the result i want, i know there r somethin wrong with the if statement and the method..but i cannot fix it.
Thank everyone who can give me some tips or help.
here is my class
* To change this template, choose Tools | Templates
* and open the template in the editor.
package javaapplication1;
* @author Administrator
public class Fan {
    private int speed;
    private boolean on;
    private double radius;
    private String color;
    Fan(int speen, boolean on, double raidus, String color)
        this.speed = 1;
        this.on = false;
        this.radius = 5.0;
        this.color = "Blue";
    public int getSpeed()
        return speed;
    public void setSpeed(int speed)
        this.speed = speed;
    public boolean isOn()
        return on;
    public void setIsOn(boolean on)
        this.on = on;
    public double getRadius()
        return radius;
    public void setRadius(double radius)
        this.radius = radius;
    public String getColor()
        return color;
    public void setColor(String color)
        this.color = color;
    public String fanSpeed()
        String output = "";
       if(speed == 1)
           return output = "slow";
       else if(speed == 2)
           return output = "Medium";
       else
           return output = "Fast";
    public String IsFanon()
        String output = "";
        if(on == false)
            return output = "the fan is off";
        else
            return output = "the fan is on";
}Here is my main class
* To change this template, choose Tools | Templates
* and open the template in the editor.
package javaapplication1;
* @author Administrator
import javax.swing.JOptionPane;
public class testFan {
     * @param args the command line arguments
    public static void main(String[] args) {
        Fan fan1 = new Fan(3, true, 10.0, "yellow");
        Fan fan2 = new Fan(2, false, 5.0, "blue");
        System.out.println("speed1 is" + "  " +fan1.fanSpeed() + ",  " + fan1.IsFanon() + ", " + "the radius is" +fan1.getRadius() + fan1.getColor());
        System.out.println("speed2 is" + "  " + fan2.fanSpeed() + ",  " + fan2.IsFanon() + ", " + "the radius is" + fan2.getRadius() + fan2.getColor());
}

Peter__Lawrey wrote:
I would not suggest using a variable like "onoff". What would true mean, is it on or off or onoff (alternating)? e.g. an on-off relationship is one which is not clearly on or off for long.
You could just use an IDE to generate the constructor which would be simpler, however if there is no good reason to have two names for parameters and fields I would make them the same.I was wondering what a "speen" is.

Similar Messages

  • Need help for creat apple id in iphone 5s

    need help for creat apple id in iphone 5s

    See this support document for instructions. http://support.apple.com/kb/HT2731

  • Need help in Creating classes for my assignment

    Hi ,
    I just started learning Java and have the following requirement
    1)     Create the following classes/interfaces using descriptions:
    a)     Account � data members : id:String, type:String, balance:BigDecimal, methods : Account, Account with String parameter, getId, getType, getBalance, setId, setType, setBalance, deposit, withdraw, compareTo, toString
    b)     Bank � data members: instance:Bank, accountsMap:Map, customersMap:Map, customersAccount:Map, transactionMap:Map, methods: getAccountsMap, getCustormersMap, getCustomersAccounts, getTransactionMap, associate, addTransaction, getAccount, getCustomer, getAccounts, getTransactions, deposit, withdraw, transfer
    c)     AccountDoesNotExistException, BankException, CustomerDoesNotExistException, InsufficientFundsException, InvalidAmountException, ZeroAmountException
    2)     Create the util package using the following class
    a)     AmountConverter � methods: fromDecimal(BigDecim     al), fromString(String)
    In 1 b how to Create Instance:bank in the class .Also how to do part2.If possible can you help me with all the parts.Based on these I've some more to do.

    Here is what I've come with
    ACCOUNT.JAVA
    import java.math.*;
    public class Account {
    private String Id;
    private String Type;
    private BigDecimal balance;
    public Account( ) {
    public Account(String Id,String Type,BigInteger balance) {
    this.Id = Id;
    this.Type = Type;
    this.balance = balance;
    public String getId( ) {
    return Id;
    public void setId(String Id) {
    this.Id = Id;
    public String getType( ) {
    return Type;
    public void setType(String Title) {
    this.Title = Type;
    public String getBalance( ) {
    return id;
    public void setBalance(String balance) {
    this.balance = balance;
    public String withdraw( ) {
    public String deposit( ) {
    public void setLastName(String LastName) {
    this.id = id;
    CUSTOMER.JAVA
    public class Customer {
    private String Id;
    private String Title;
    private String firstName;
    private String lastName;
    /** Construct a Customer with no data -- must be a no-argument */
    public Customer( ) {
    /** Construct a Customer with String Parameter */
    public Customer(String Id,String Title,String firstName,String lastName) {
    this.Id = Id;
    this.Title = Title;
    this.firstName = firstName;
    this.lastName = lastName;
    /** Return the Id. */
    public String getId( ) {
    return Id;
    /** Set the Id */
    public void setId(String Id) {
    this.Id = Id;
    /** Return the Title */
    public String getTitle( ) {
    return Title;
    /** Set the Title */
    public void setTitle(String Title) {
    this.Title = Title;
    /** Return the Firstname. */
    public String getFirstName( ) {
    return id;
    /** Set the Firstname. */
    public void setFirstName(String FirstName) {
    this.id = id;
    /** Return the Lastname. */
    public String getLastName( ) {
    return LastName;
    /** Set the Lastname. */
    public void setLastName(String LastName) {
    this.id = id;
    TRANSRECORD.JAVA
    import java.util.*;
    import java.math.*;
    public class TransRecord implements Comparable{
    private Date timeStamp;
    private String transType;
    private BigDecimal transAmt;
    /** Construct a Trans Record with no data -- must be a no-argument */
    public TransRecord( ) {
    /** Construct a Customer with String Parameter */
    public Customer(String transType,String transAmt) {
    this.transType = transType;
    this.transAmt = transAmt;
    /** Return the timeStamp. */
    public String gettimeStamp( ) {
    return timeStamp;
    /** Set the timeStamp */
    public void settimeStamp(Date timeStamp) {
    this.timeStamp = timeStamp;
    /** Return the TransType */
    public String getTransType( ) {
    return TransType;
    /** Set the TransType */
    public void setTransType(String TransType) {
    this.TransType = TransType;
    /** Return the TransAmt */
    public String getTransAmt( ) {
    return TransAmt;
    /** Set the TransAmt */
    public void setTransAmt(String TransAmt) {
    this.TransAmt = TransAmt;
    /** Return a String representation. */
    public String toString( ) {
    /** CompareTo method */
    public int compareTo(Object argument)
    ===============
    ACCOUNTDOESNOTEXISTEXCEPTION.JAVA
    public class AccountDoesNotExistException
                   extends Exception
         public AccountDoesNotExistException()
              super();
         public AccountDoesNotExistException(String message)
              super(message);
    =================
    BANKEXCEPTION.JAVA
    public class BankException
                   extends Exception
         public BankException()
              super();
         public BankException(String message)
              super(message);
    CUSTOMERDOESNOTEXISTEXCEPTION.JAVA
    public class CustomerDoesNotExistException
                   extends Exception
         public CustomerDoesNotExistException()
              super();
         public CustomerDoesNotExistException(String message)
              super(message);
    ACCOUNTDOESNOTEXISTEXCEPTION.JAVA
    public class AccountDoesNotExistException
                   extends Exception
         public AccountDoesNotExistException()
              super();
         public AccountDoesNotExistException(String message)
              super(message);
    INSUFFICIENTFUNDSEXCEPTION.JAVA
    public class InsufficientFundsException
                   extends Exception
         public InsufficientFundsException()
              super();
         public InsufficientFundsException(String message)
              super(message);
    INVALIDAMOUNTEXCEPTION.JAVA
    public class InvalidAmountException
                   extends Exception
         public InvalidAmountException()
              super();
         public InvalidAmountException(String message)
              super(message);
    ZEROAMOUNTEXCEPTION.JAVA
    public class ZeroAmountException
                   extends Exception
         public ZeroAmountException()
              super();
         public ZeroAmountException(String message)
              super(message);
    I need help with Bank Class and the util class.Correct me If I've missed any exceptions or if any syntax is wrong
    THanks
    AKsh

  • Need help for creating sharepoint sites for both internet and intranet users

    We would like to know what is the best approach to create SharePoint sites for our customers(internet users) and internal employees(intranet users) on the same SharePoint server. Here is the scenario:
    1) A customer posts a document from internet.
    2) This triggers a approval workflow that can only be accessed and executed in the intranet environment. This approval process requires approval's possible modifications to the customer's document.
    3) We would like the customer not to able to check the approval state and the modified document until the document is fully approved and finalized.
    We are pondering if we need to create two sites, one site for customer and the other site is for internal approvers. Or one site is possible. It also looks like we need to somehow copy customer's original document to intranet site and triggers the workflow.
    Any design ideas are helpful. Thank you advance!

    Hi Jason,
    Though it is perfectly possible to have both intranet and internet on the server, it is not a recommended practice. Having both on the same server would have multiple problems, instead me detailing it out, here is a forum thread on which Trevor had given
    enough reasons -
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/9b550c33-6f5f-4cd9-8762-8ff389b747d9/sharepoint-2013-one-farm-to-host-intranet-extranet-internet?forum=sharepointadmin
    If you have valid reason to go with single server, then you can also explore email enabled lists as one option and another one would be using custom sharepoint designer workflow.
    you can also try using event receivers to send documents to intranet site from internet site, process everything and update the document in the internet site.
    Hope this helps!
    Ram - SharePoint Architect
    Blog - SharePointDeveloper.in
    Please vote or mark your question answered, if the reply helps you

  • Need help w/ created classes and objects

    I am having a difficult time understanding what is wrong w/ my classes and objects. I've looked in two books and have messed around a bit. Here is what I am -attempting- to do.
    I want to make a class called CLOTHING. In this class i want objects such as shirt and pants (for now).
    these are the errors im getting:
    .\Shirt.java:6: invalid method declaration; return type required
         public Shirt(int size){
                   ^
    .\Shirt.java:3: class Clothing is public, should be declared in a file named Clothing.java
    public class Clothing {
           ^
    MyClassHW.java:10: cannot resolve symbol
    symbol  : constructor Shirt  (int,int)
    location: class Shirt
              myShirt = new Shirt(1,1);
                              ^
    3 errors------------------------------------------------------------
    This is the code for my Clothing class:
    import java.awt.*;
    public class Clothing {
         private int shirtSize;
         private void Shirt(Graphics s, int h, int v){
         Polygon shirts;
              shirts = new Polygon();
              shirts.addPoint(5+h,8+v); // 1
              shirts.addPoint(17+h,12+v); // 2
              shirts.addPoint(19+h,13+v); // 3
              shirts.addPoint(33+h,8+v); // 4
              shirts.addPoint(37+h,13+v); // 5
              shirts.addPoint(25+h,20+v); // 6
              shirts.addPoint(25+h,28+v); // 7
              shirts.addPoint(15+h,28+v); // 8
              shirts.addPoint(15+h,20+v); // 9
              shirts.addPoint(1+h,12+v); //10
              s.fillPolygon(shirts);
    }from what i understand each object is essentially a method...
    Here is the code for the java applet I'm making:
    import java.awt.event.*;
    import java.awt.*;
    import java.applet.*;
    public class MyClassHW extends Applet { // implements ActionListener, AdjustmentListener {
         Shirt myShirt;
         int size;
         public void init(){
              myShirt = new Shirt(1,1);
    // <applet code = "MyClassHW.class" height = 300 width=300> </applet>thank you for your time and help. as always, your efforts are appriciated.

    .\Shirt.java:6: invalid method declaration; return type required     public Shirt(int size){
    I guess, public Shirt(int size) is constructor in class shirt. You have one int in this constructor. Shirt(int size)
    Here you initialize your shirt with two int:
    MyClassHW.java:10: cannot resolve symbolsymbol : constructor Shirt (int,int)location: class Shirt          myShirt = new Shirt(1,1);
    Shirt(int size, int what?)
    It's why it show such message.
    But even if you fix it seems like you have very vague ideas about what you are doing.
    As far as I understood you need three classes.
    First applet Clothing:
    public class Clothing extends Applet{
    Shirt myShirt;
    Pants myPants;
    public void init() {
    myShirt = new Shirt(1); // small shirt
    myPants = new Pants(32, 40); // medium waist and long legs
    Second and third your classes Shirt and Pants:
    public class Shirt extends Object {
    int size;
    public Shirt(int s) {
    size = s;
    public int getSize () {
    return size;
    same for Pants, only you need two parameters for it or whatever you want.
    You could design it diffrently if you want derive your Shirts and Pants from Clothing and then to use them in your applet. But, indeeed, you desperately have to do some serious reading, where authors are accurate in they definitions and stuff, because it's kind of complicated.

  • Need help for creating a Transaction iView

    Hi all,
    I wish to make a Transaction iView using a transaction from the SAP BW system. Our SSO is working fine (since we are able to run the BI Reports in Portal).
    When I use SAP GUI for Windows in my Transaction iView, then the transaction is shown alongwith the header including the transaction input field. I basically want the transaction without this header.
    When I use SAP GUI for HTML in my Transaction iView, then everytime I run this iView, I am being asked for the R/3 user id and password. (See this [screenshot|http://img171.imageshack.us/my.php?image=transactioniviewzw8.jpg]). Once I give the user id and password, the transaction runs without the header. But in this case, I want to open the transaction directly without the need to give the user id and password.
    Can you please help me as to what can be done?
    Regards,
    Ankur

    Hello Ankur,
    Please go through the link below.
    [To remove transaction bar from the R/3 Reports shown on Portal.|To remove transaction bar from the R/3 Reports shown on Portal.]
    I had the same issue.
    Cheers-
    Pramod

  • I Need help for creating rules - very high values !!

    Hi,
    i have some troubleshooting by creating rules at HFM 11.1.1.3. I have declarate an array where some Data from an Account is stored. Then there should be stored one of the numerical data in another HFM account (f.e. "EB_MITTEL"). The stored data is much higher than the value in the log file ("write2File") showed. If i divide this value by 100000000000000 then the right value will be reported.
    Example: Value in log-file: 16492,8691588785 ("," = decimal-delimiter)
    Value in the Data-Grid: 164.928.691.588.785 ("." = thousands-separator)
    Part of the rule-file:
    Sub
         Dim lMittelWert, lMaxWert, lMinWert
         lMittelWert = 0
         lMaxWert = 0
         lMinWert = 0
         a = 0
         For x = 1 To 13
              If arListe(x) <> 0 then
              lMittelWert = lMittelWert + arListe(x)
              a=a+1
              End if
              If lMaxWert < arListe(x) Then
                   lMaxWert = arListe(x)
              End If
              if x = 1 then
                   lMinWert = arListe(x)
              End if
         Next
         lMinWert = lMaxWert
         For x = 1 To 13
              If lMinWert > arListe(x) and arListe(x) <> 0 Then
                   lMinWert = arListe(x)
              End If
              write2file arListe(x)
         Next
         if a <> 0 Then
              lMittelWert = lMittelWert / a
         End if     
         HS.Exp "A#EB_MITTEL.C1#" & C1Item & " = " & lMittelWert
         HS.Exp "A#EB_MIN.C1#" & C1Item & " = " & lMinWert
         HS.Exp "A#EB_MAX.C1#" & C1Item & " = " & lMaxWert
    End Sub
    I hope someone can help me, many thanks in advance. (and i am so sorry about my bad english)
    Juergen

    VB Scripts using String to number conversions in some languages require special consideration when handling numbers. (e.g. French, German and others that use commas as decimal delimiter).
    Internally, HFM VB Scripts use periods (.) as the decimal delimiter. One workaround is to force the use of decimals and force the Scripting engine to use decimals by declaring the local to be English US with:
    b = setLocale("en-us")

  • Need help for create A and MX records (home server)

    What should I put in the DNS (A record, MX) to be able to receive email from my provider Godaddy and send emails directly from my server without passing through Godaddy.
     The server is "home server" and it is not always access (open).
     Incoming Mail: from Godaddy
     Outgoing Mail: form my server

    Hi,
    Based on my knowledge, the default receive connectors are automatically created when the Exchange server is installed. Then the internal and outbound mails can delivered properly through Exchange server. After we create send connector and add public MX record
    and A record on the public DNS server, the inbound mails can be delivered. And we can set the send connector with MX record, then the inbound mails are directly delivered by Exchange server.
    If you have any question, please feel free to let me know.
    Thanks,
    Angela Shi
    TechNet Community Support

  • Need help in creating RAID 5

    Hi everyone,
    i'm fairly new to RAID scene and i need help for creating RAID 5 with 8 disk's. 
    I have HP ProLiant DL380 G6 with 8 disk's, each 500 GB.
    i'm trying to create RAID 5 and to have one spare disk. I have made array from 7 disk and then create logical drive.
    the last disk (8-th) i used as spare. 
    up to now i think i'm ok???
    what confuse me is:
    7 HDD X 500GB= 3500GB
    after creating array i get 3200 GB, where i lose 300 GB??
    after creating logical drive i get 2700 GB, where i lose 500 GB???
    from 2700GB i give 150GB for system partition and for data storage i have only 2550 GB.
    Why i lose 800GB??
    Can someone explain me how RAID 5 works, do i create it correctly and why i lose so much space???
    Is there other way to create RAID 5 without losing so much space? 
    Thanks you in advnce. 

    The first 'loss' you encounter (300MB) is due to megabyte counting/rounding.  A 500GB disk contains about 500.000.000 bytes. This quite a bit less than if counted properly using binary. you loose about 24288000 bytes per disk this way!
    http://en.wikipedia.org/wiki/Mibibyte |
    http://en.wikipedia.org/wiki/Megabyte
    the second loss is due to how raid works.in raid 5 data is written to multiple disks to improve reliability. the simplies t form uses 3 disks: a write will cause half of the data to be written to disk 1, half to disk 2 and the XOR of both datahalfs to disk
    3. In this scenario you will loose 33% of storage space and you can loose up to one of 3 disks.
    By adding more disks, data can be spread more and the ratio available/raw will increase, or you can write aditionnal crc data and increase resliency for failures.
    http://en.wikipedia.org/wiki/RAID
    To check the exact algoritmes using on you RAID adapter, I would recommend contacting the vendor (or checking their support site) From your numbres, I do not think you will be able to configure RAID 5 on the same disks and having more available
    space for your data.
    MCP/MCSA/MCTS/MCITP

  • Need Help to create new screen for RF Sapconsole

    Hi Guru's
    I'm new on RF (but some years in ABAP) since last week.
    I need help to create new screens for RF (SAPLLMOB).
    Can someone explain me the procedure to create screen (with ABAP code after) or perhaps someone have an exemple (simple or not) ?
    I have to develop 2 new screens with really few time.
    And, another subsidiary question :
    how SAP can transfert information between the flash gun and the screen i have developped.
    Is there some code to add to enable this functionality or it is include in SAPLLMOB on standard fields ????
    It's a new strange world for me today...
    Many thanks to everyone who can explain me
    Alain

    hi,
    I am facing this problem as well. Is there any reference to create the new screen?
    Hope someone can help! Thanks!
    Regards,
    Darren

  • I need help for actionscript 3, sending php info to my email, website created in Flash cs5 pro

    Hi,  My name is David and I followed a course creating my own website from Lynda.com by Paul Trani. After that I created my first own webste. After I finished it, everything was working well in flash and firefox. I have only one problem and question concerning the feed back form for sending info from my website to my emailaddres. I created my website “LisbonDreamWalking”in Flash CS5 pro. I herein have a contact page, where people can send an email for a walk in Lisbon, date,the number of people etc. Now I want through my ISP / host funpic.org, that the input, info text fields to be sended to my emailaddress [email protected]. My mail URL adress  iss: http://lisbondreamwalk.li.funpic.org  This is a free host, so they don't work with forms like in the course, and I need some additional info for the php. Here is my HTML (Flash actionscript 3.0) for the sending I only have the red text to fill in (php), I was told by the adobe course.I really hope someone can help me?! Thanks in advance!
    Instructions: 1. Add your custom code on a new line after the line that says "// Start your custom code" below. The code will execute when the symbol instance is clicked. */  send_btn.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_13);  function fl_MouseClickHandler_13(event:MouseEvent):void {          if (thename.text == "" || theemail.text == "" || thetime.text == "" || thepersons.text == "" || themessage.text == "")      {           thankyou.text = "please fill out all fields";      }      else      {           // create a variable container           var allVars : URLVariables = new URLVariables();           allVars.name = thename.text;           allVars.email = theemail.text;           allVars.time = thetime.text;           allVars.persons = thepersons.text;           allVars.message = themessage.text;           //Send info to a URL           var mailAddress:URLRequest = new URLRequest("http.www.namewebsite.com/gdform.php");           mailAddress.data = allVars;           mailAddress.method = URLRequestMethod.POST;           sendToURL(mailAddress);            thankyou.text = "Thank YOU!";           thename.text = "";           theemail.text = "";           thetime.text = "";           thepersons.text = "";           themessage.text = "";      } }
    H

    Thank you Kglad, I am going to see if I can make it work. I will let you know!
    Date: Thu, 13 Oct 2011 08:55:05 -0600
    From: [email protected]
    To: [email protected]
    Subject: I need help for actionscript 3, sending php info to my email, website created in Flash cs5 pro
        Re: I need help for actionscript 3, sending php info to my email, website created in Flash cs5 pro
        created by kglad in Action Script 3 - View the full discussion
    you missed part of the tutorial (or the tutorial is incomplete):  send_btn.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_13); function fl_MouseClickHandler_13(event:MouseEvent):void{     if (thename.text == "" || theemail.text == "" || thetime.text == "" || thepersons.text == "" || themessage.text == "") { thankyou.text = "please fill out all fields"; } else { // create a variable container var allVars : URLVariables = new URLVariables(); allVars.name = thename.text; allVars.email = theemail.text; allVars.time = thetime.text; allVars.persons = thepersons.text; allVars.message = themessage.text; //Send info to a URLvar mailAddress:URLRequest = new URLRequest("http.www.namewebsite.com/gdform.php"); mailAddress.data = allVars; mailAddress.method = URLRequestMethod.POST; sendToURL(mailAddress);
    }}  var urlLoader:URLLoader=new URLLoader(); function sendToURL(mailAddress):void{urlLoader.addEventListener(Event.COMPLETE,completeF);urlLoade r.load(mailAddress);} function completeF(e:Event):void{ thankyou.text = "Thank YOU!"; thename.text = ""; theemail.text = ""; thetime.text = ""; thepersons.text = ""; themessage.text = "";}
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/3969414#3969414
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/3969414#3969414. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Action Script 3 by email or at Adobe Forums
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • I need help with Creating Key Pairs

    Hello,
    I need help with Creating Key Pairs, I generate key pais with aba provider, but the keys generated are not base 64.
    the class is :
    import java.io.*;
    import java.math.BigInteger;
    import java.security.*;
    import java.security.spec.*;
    import java.security.interfaces.*;
    import javax.crypto.*;
    import javax.crypto.spec.*;
    import au.net.aba.crypto.provider.ABAProvider;
    class CreateKeyPairs {
    private static KeyPair keyPair;
    private static KeyPairGenerator pairGenerator;
    private static PrivateKey privateKey;
    private static PublicKey publicKey;
    public static void main(String[] args) throws Exception {
    if (args.length != 2) {
    System.out.println("Usage: java CreateKeyParis public_key_file_name privete_key_file_name");
    return;
    createKeys();
    saveKey(args[0],publicKey);
    saveKey(args[1],privateKey);
    private static void createKeys() throws Exception {
    Security.addProvider(new ABAProvider());
    pairGenerator = KeyPairGenerator.getInstance("RSA","ABA");
    pairGenerator.initialize(1024, new SecureRandom());
    keyPair = pairGenerator.generateKeyPair();
    privateKey = keyPair.getPrivate();
    publicKey = keyPair.getPublic();
    private synchronized static void saveKey(String filename,PrivateKey key) throws Exception {
    ObjectOutputStream out= new ObjectOutputStream(new FileOutputStream(filename));
    out.writeObject(key);
    out.close();
    private synchronized static void saveKey(String filename,PublicKey key) throws Exception {
    ObjectOutputStream out= new ObjectOutputStream( new FileOutputStream(filename));
    out.writeObject(key);
    out.close();
    the public key is:
    �� sr com.sun.rsajca.JSA_RSAPublicKeyrC��� xr com.sun.rsajca.JS_PublicKey~5< ~��% L thePublicKeyt Lcom/sun/rsasign/p;xpsr com.sun.rsasign.anm����9�[ [ at [B[ bq ~ xr com.sun.rsasign.p��(!g�� L at Ljava/lang/String;[ bt [Ljava/lang/String;xr com.sun.rsasign.c�"dyU�|  xpt Javaur [Ljava.lang.String;��V��{G  xp   q ~ ur [B���T�  xp   ��ccR}o���[!#I����lo������
    ����^"`8�|���Z>������&
    d ����"B��
    ^5���a����jw9�����D���D�)�*3/h��7�|��I�d�$�4f�8_�|���yuq ~
    How i can generated the key pairs in base 64 or binary????
    Thanxs for help me
    Luis Navarro Nu�ez
    Santiago.
    Chile.
    South America.

    I don't use ABA but BouncyCastle
    this could help you :
    try
    java.security.Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
    java.security.KeyPairGenerator kg = java.security.KeyPairGenerator.getInstance("RSA","BC");
    java.security.KeyPair kp = kg.generateKeyPair();
    java.security.Key pub = kp.getPublic();
    java.security.Key pri = kp.getPrivate();
    System.out.println("pub: " + pub);
    System.out.println("pri: " + pri);
    byte[] pub_e = pub.getEncoded();
    byte[] pri_e = pri.getEncoded();
    java.io.PrintWriter o;
    java.io.DataInputStream i;
    java.io.File f;
    o = new java.io.PrintWriter(new java.io.FileOutputStream("d:/pub64"));
    o.println(new sun.misc.BASE64Encoder().encode(pub_e));
    o.close();
    o = new java.io.PrintWriter(new java.io.FileOutputStream("d:/pri64"));
    o.println(new sun.misc.BASE64Encoder().encode(pri_e));
    o.close();
    java.io.BufferedReader br = new java.io.BufferedReader(new java.io.FileReader("d:/pub64"));
    StringBuffer keyBase64 = new StringBuffer();
    String line = br.readLine ();
    while(line != null)
    keyBase64.append (line);
    line = br.readLine ();
    byte [] pubBytes = new sun.misc.BASE64Decoder().decodeBuffer(keyBase64.toString ());
    br = new java.io.BufferedReader(new java.io.FileReader("d:/pri64"));
    keyBase64 = new StringBuffer();
    line = br.readLine ();
    while(line != null)
    keyBase64.append (line);
    line = br.readLine ();
    byte [] priBytes = new sun.misc.BASE64Decoder().decodeBuffer(keyBase64.toString ());
    java.security.KeyFactory kf = java.security.KeyFactory.getInstance("RSA","BC");
    java.security.Key pubKey = kf.generatePublic(new java.security.spec.X509EncodedKeySpec(pubBytes));
    System.out.println("pub: " + pubKey);
    java.security.Key priKey = kf.generatePrivate(new java.security.spec.PKCS8EncodedKeySpec(priBytes));
    System.out.println("pri: " + priKey);
    catch(Exception e)
    e.printStackTrace ();
    }

  • Need help in creating Database connection to Apache 4

    I desperately need help for my project. I'm doing a shopping cart project. Created a java bean to establish connection to my sql 7 server database. But the following always appear. I'm using dreamweaver mx to create my webpage and so I use its binding and components feature.
    Here's the error message I always get..
    org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
    An error occurred at line: 36 in the jsp file: /TMP8ouafocg7v.jsp
    Generated servlet error:
    C:\tomcat4\work\Standalone\localhost\ArtGallery\TMP8ouafocg7v$jsp.java:163: Class org.apache.jsp.DBConn not found.
    DBConn connect = null;
    ^
    An error occurred at line: 36 in the jsp file: /TMP8ouafocg7v.jsp
    Generated servlet error:
    C:\tomcat4\work\Standalone\localhost\ArtGallery\TMP8ouafocg7v$jsp.java:166: Class org.apache.jsp.DBConn not found.
    connect= (DBConn)
    ^
    An error occurred at line: 36 in the jsp file: /TMP8ouafocg7v.jsp
    Generated servlet error:
    C:\tomcat4\work\Standalone\localhost\ArtGallery\TMP8ouafocg7v$jsp.java:171: Class org.apache.jsp.DBConn not found.
    connect = (DBConn) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "DBConn");
    ^
    3 errors, 1 warning
    Anyone out there, pls let me know the solution soon. Thanks!

    I was glad I came across this note. I recently started a tutorial on J2EE , and have run into exactly the same error. Have you found a solution? Can you share it with me?
    Thanks.....

  • Need help for flash builder

    i need help for flash builder 4 and papervison 3d. I need to create a slider with it ranges of value from 10 to 50 to adjust the camera values for the camera.fov and also need to create it for the yaw of the object from 0 to 360. I try to look for any slider event and classes in this program but cant find any, btw, i need to use the AS only project file.
    here is my codes:
    can you please tell me how i should modify the codes?
    package
        import flash.display.BitmapData;
        import flash.display.Sprite;
        import flash.events.Event;
        import org.papervision3d.materials.BitmapFileMaterial;
        import org.papervision3d.materials.BitmapMaterial;
        import org.papervision3d.objects.primitives.Sphere;
        import org.papervision3d.view.BasicView;
        [SWF (width="800", height="600", backgroundColor="0x000000",frameRate="30")]
        public class EarthBitmap extends BasicView
            private var sphere:Sphere;
            public function EarthBitmap()
                super(800 , 600);
                var earthmaterial:BitmapFileMaterial = new BitmapFileMaterial("../assets/Earth.jpg");
                sphere = new Sphere(earthmaterial,100,20,18);
                camera.fov = 25;
                scene.addChild(sphere);
                addEventListener(Event.ENTER_FRAME,rotateSphere);
            public function rotateSphere(evt:Event):void
                sphere.yaw(0.2);
                singleRender();

    Turn the click handler into a full on separate function. Then store all the views in an array and use Math.rand() to randomly choose one.
    Something like this:
    <fx:Script>
         <![CDATA[
              var questionsArray:Array = {question2,question3,question5,questionRed,questionGeography};
              function buttonClickHandler(event:MouseEvent){
                   var randomProblem:int = Math.floor(Math.random()*(questionsArray.length));     //generates a random integer between 0 and the total number of questions in the array (arrays are 0-based)
                   navigator.pushView(questionsArray[randomProblem]);
         ]]>
    </fx:Script>
    <s:Button id="randomProblemButton" label="Next Problem" click="buttonClickHandler(event)" />
    Haven't tested that, but something along that line should work

  • Need help to create report with jpeg/gif image

    Hello,
    I need help with creating a form with a special jpeg/gif seal. I never done this Java. Until now, I created all forms with ansi C++ with HP escape characters to draw lines, boxs, and text. This form will contain boxes which is populated with database information read from a text file.
    Since this form contains a special seal on the upper right, I don't think it can be done with old fashion ansi C++. How can I create a form with Java and create it as a simple exe to just print the form to a specified printer.
    Thanks,
    John

    Hi,
    I am creating a form with boxes (lines and text). What is special about this form is that it has an image jpeg or gif at the top right corner. Is is a state department seal. Up to this form, I had used ansi C++ and print out escape HP character to print out the lines, boxes, and text. I have no idea how to print out the image. I am new to JAVA and only 1 class in it. Is there sample code out there to create this type of form with the image? I need a starting point.
    Thanks,
    John

Maybe you are looking for

  • Warning: java 7 and BT speedtest

    Warning:  As has been pointed out here and on other forums, the BT speedtester is not compatible with Java 7.  This was previously a techie problem, but now Oracle seem to be rolling out Java 7 to 'ordinary' users.  If you are using the BT speedtests

  • How to share with users?

    Hello! I am an administrator user. I created a managed user for my little sister and I don't know how to share with her my iTunes library. How can I do that? Thanks in advance, Camille

  • Aperture wants the original serial number and I don't have it!!?!!

    I upgraded to a newer iMac and migrated all my files over to it. When I tried to open Aperture it asks for the serial number (I have 2.1.4). No worries, I input the serial number. Then it says that my serial number is for an upgrade and it wants the

  • DVCPro HD 60P in a 24P timeline (From HPX 500 /  P2card)

    I've been playing with the new DVCProHD features in CS3.1, and I am wondering if there is a way to actually bring full 60P footage in a 24P timeline to slow it down. From what I read in the project settings, it doesn't seem possible. Although it read

  • Getting the following error when upgrading designer repository

    Hello All, I`m going through the upgrade of the designer repository from 6i to 10gR2 and I get the following error in the log file ckprereq.log. The weird thing is from the GUI everything looked ok. It`s when i went to the individual log files tha ti