Problem in catching UserException

I have a problem in catching UserException in the JavaCard RMI demo of purse client from the Development Kit. The error that i'm getting is this, instead of catching the UserException:
Exception in thread "main" java.lang.UnsatisfiedLinkError: com.sun.javacard.impl.NativeMethods.getCurrentContext()B
     at com.sun.javacard.impl.NativeMethods.getCurrentContext(Native Method)
     at com.sun.javacard.impl.PrivAccess.getCurrentAppID(PrivAccess.java:454)
     at javacard.framework.CardException.<init>(CardException.java:46)
     at javacard.framework.UserException.<init>(UserException.java:49)
     at com.sun.javacard.javax.smartcard.rmiclient.CardObjectFactory.throwIt(Unknown Source)
     at com.sun.javacard.javax.smartcard.rmiclient.CardObjectFactory.throwException(Unknown Source)
     at com.sun.javacard.javax.smartcard.rmiclient.CardObjectFactory.getObject(Unknown Source)
     at com.sun.javacard.rmiclientlib.JCRemoteRefImpl.parseAPDU(Unknown Source)
     at com.sun.javacard.rmiclientlib.JCRemoteRefImpl.invoke(Unknown Source)
     at card.PurseImpl_Stub.setAccountNumber(Unknown Source)
     at client.PurseClient.main(PurseClient.java:88)The client aplication from the demo works fine, but at the end it was supposed to generate a UserException. The result that I get is this:
Receiving initial reference... OK
Getting the balance... Balance = 0
Crediting 20...
Debiting 15...
Getting the new balance... Balance = 5
Setting account number equal to 54321...
Getting the account number...  5 4 3 2 1
Trying to set incorrect (too long) account number. Expecting to get UserException with code=0x6002
Exception in thread "main" java.lang.UnsatisfiedLinkError: com.sun.javacard.impl.NativeMethods.getCurrentContext()B
     at com.sun.javacard.impl.NativeMethods.getCurrentContext(Native Method)
     at com.sun.javacard.impl.PrivAccess.getCurrentAppID(PrivAccess.java:454)
     at javacard.framework.CardException.<init>(CardException.java:46)
     at javacard.framework.UserException.<init>(UserException.java:49)
     at com.sun.javacard.javax.smartcard.rmiclient.CardObjectFactory.throwIt(Unknown Source)
     at com.sun.javacard.javax.smartcard.rmiclient.CardObjectFactory.throwException(Unknown Source)
     at com.sun.javacard.javax.smartcard.rmiclient.CardObjectFactory.getObject(Unknown Source)
     at com.sun.javacard.rmiclientlib.JCRemoteRefImpl.parseAPDU(Unknown Source)
     at com.sun.javacard.rmiclientlib.JCRemoteRefImpl.invoke(Unknown Source)
     at card.PurseImpl_Stub.setAccountNumber(Unknown Source)
     at client.PurseClient.main(PurseClient.java:88) Have anybody had this problem when running the RMI demo from the development kit?
Edited by: Traveller83 on Feb 19, 2009 3:11 PM
Update: I'm using JDK 1.6 and I already have tried 1.5, and still have this problem. Also, I get this problem by running either CREF and JCWDE.
It seems that when the runtime environment calls getCurrentContext() from the NativeMethods class it gives an error. The application runs well, and this only happens when a UserException is thrown by the card. All the samples in the javacard kit 2.2.2 gives this problem when the card throws an UserException. Please I need help on this problem, I can't find a solution anywhere...
Thanks in advance.
Edited by: Traveller83 on Feb 19, 2009 11:27 PM

Problem resolved.
I'm using Eclipse for the development of JavaCard applets and the host side. So, i had all the librabries from the JavaCard Kit all along in the same project. When the client application tried to catch an exception thrown by the card some conflicts surged.
To fix this,if you're using Eclipse for the development, you have to separate the necessary libraries for the card from those necessary for the host applications. Now I have two projects, one for the client applications and another for the card side.

Similar Messages

  • Problem in catching Exception

    I am using servlets. In my program after a particular point I am not able to catch an Exception if it occurs.
    And after this point whatever Exception occurs that is not coming to catch block and its getting printed in webserver logs.
    Can someone help me
    Thanks

    Two possibilities:
    -First you might be catching checked exceptions but not unchecked exceptions. You can catch all types of exceptions by using a catch(Throwable) rather, or in addition to, a catch(Exception)
    -Second, you might be able to catch the exception at the top level and will have to instead add it to many of your methods instead. The reason is that your code might be called in an application server thread. And exceptions are not propogated out of a thread. But if you didn't create it you have no control over it. So your only choice is to add exception/thowable catches in many of your methods.

  • Problem in catching the User status of a WBS Element

    Hi All,
          In CJ20n transaction we need to catch the User status for a particular WBS element when it gets changed to 'Technically Completed(TECO)' so that we can create an asset.
         At present we are using the method <b>'AT_SAVE'</b> of the BADI <b>'WORKBREAKDOWN_UPDATE'</b> in which we are unable to catch the user status since the user status is not getting updated in the JEST table at that time.
        We have tried calling a function module in Update task but in that also the JEST table is not getting updated.
    Please provide us the solution.
    Thanks and Regards,
        Siva

    Hi Siva,
    Try the following BADIs
    WBS_FIELDS_FOR_ASSET
    WBS_MULTIPLE_ECP
    If these do not solve your purpose, then there is a work around..
    1). Goto the transaction CJ20n -> goto the User Status Screen -> On the User Status check box press F1 -> Goto technical information. Get the Structure and field name of the Status.
    2). This structure will be filled up with the current value during the program execution. You can get the value from this Structure.
    Hope it helps...
    Lokesh

  • C# -- Problem to Catch MenuEvent

    Hi all,
    The Menu Event it does not come intercepted
    This is the Menu that I've insert
    menuItem =  this.appl.Menus.Item("43520");
    mnuPkg.Type = SAPbouiCOM.BoMenuType.mt_POPUP;
    mnuPkg.String     = "Add-in";     
    mnuPkg.UniqueID = "D3F_AINSCO";
    mnuPkg.Enabled     = true;
    mnuPkg.Position = menus.Count;
    menus = menuItem.SubMenus;
    menus.AddEx(mnuPkg);
    menuItem = menus.Item("D3F_AINSCO");
    mnuPkg.Type= SAPbouiCOM.BoMenuType.mt_STRING;
    mnuPkg.String     = "Manage";
    mnuPkg.Enabled     = true;
    mnuPkg.Position = menus.Count;
    mnuPkg.UniqueID = "D3F_MNT";
    menus = menuItem.SubMenus;
    menus.AddEx ( mnuPkg );
    This is an Event Filter
    evnt = evnts.Add(SAPbouiCOM.BoEventTypes.et_MENU_CLICK);
    evnt.AddEx("D3F_MNT");
    This is the Handle Event  code
    private void appl_MenuEvent(ref SAPbouiCOM.MenuEvent pVal, out bool BubbleEvent)
    BubbleEvent = true;
    if ( pVal.BeforeAction == true)
       switch(pVal.MenuUID)
         case "D3F_MNT":
              this.LoadFormFromXml(   stPath + "\Gst.srf");
              break;
    When I press on menu the form doesn't loaded.. and In the MenuEvent never it enter
    where is my error??
    Bye!!!

    In which order do you catch the events?
    Know it sound silly, but I've actually seen it have inpact on what is called and what is not
    try to compare your code to the following:
    SboApplication.MenuEvent+=new _IApplicationEvents_MenuEventEventHandler(SetupMenuEvent);
    SboApplication.ItemEvent+=new _IApplicationEvents_ItemEventEventHandler(SetupItemEvent);
    SboApplication.AppEvent+=new _IApplicationEvents_AppEventEventHandler(AppEvent);     
    private static void SetupMenuEvent(ref MenuEvent pVal, out bool BubbleEvent) {
      BubbleEvent = true; //[Standard]
      if(pVal.MenuUID=="1540" && pVal.BeforeAction) {
          SboApplication.MessageBox("Pressed Journal Entry",1,"OK","","");
    Regarding why the bubbleevent set set to true... This is needed for an out param in C# so this is normal

  • Problem in Catching Double Click

    Hi,
    I have a JLabel, i override paint method of this label to draw few line, and then i add a mouse listener to this label,
    Now i want to capture a double click event, and open a dialog box, when user double clicks
    Code i have for it is as below
    public void mouseClicked(MouseEvent e)
    int i = e.getClickCount();
    System.out.println("click count " + i);
    if(e.getClickCount() >= 2)
    System.out.println("creating instance of CalOverrideAndMaintDialog");
    new CalOverrideAndMaintDialog(keyDate, lineNum);
    But the problem is, it opens 2 dialog boxes instead of 1, is it to do with speed of mouse, how can i get only 1 dialog box, is there any other better method to do this
    PS: i see this ("creating instance of CalOverrideAndMaintDialog"); printed twice
    Ashish

    hi ,
    i also wanna to increase the double click speed in my swing application.
    In ControlPanel >> Mouse Properties >> there is an option for increasing the double click speed.
    Similarly , i need to have a JSlider , getting User Input from the JSilder Object, thereby increasing the double click speed for my Swing Application.
    how to do this one in swing ???
    Also have a look at :
    http://forum.java.sun.com/thread.jsp?forum=57&thread=195316
    http://forum.java.sun.com/thread.jsp?forum=57&thread=247776
    If u have got any idea,please help me.....

  • Problem on catch error

    Hi ,
    I have cross pages download function, which is i fthe user only want to download sorecodes on one scree, just check the checked box and click the save button, if user want to download recode cross pages, the need to check the box click add more button and then click the save button.
    Now my problem is if the use did not checked any box and click the save button then I need some error message is pop up, it suppose quite sample, but I just keep got java.lang.NullPointerException, what mistake I hade makde??
    String[] checked = request.getParameterValues("mybox");
    if(checked.length>0){
    dosomething}
    else {
    error message}
    I can't handle the error message

    java.lang.NullPointerException
         formate.download.doPost(download.java:112)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:693)
         org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:660)
         org.apache.jsp.secure.Action_jsp._jspService(org.apache.jsp.secure.Action_jsp:74)

  • Problem with C4 and C5 On-Demand

    We've been using the YouView box for about three weeks, but have had some disappointing results.  On the positive side, picture quality is very good through HDMI and the pause live TV and recording all work fine.
    The main problem is with On-demand, mainly C4/C5 and related channels.  Generally BBC i-player works OK though it has occasionally failed.  Navigation through the EPG to select a past programme is excellent on YouView, but we have never succeeded in seeing any C4 or C5 programme.  Bizarrely, the Ads always play OK, but as soon as the main programme starts, the picture breaks up with severe pixcilation, crackling sound which sometimes disappears altogether and then the picture freezes and the whole thing hangs up.  Useless.
    Looks like a streaming problem with inadequate throughput.  We have BT Infinity, and I did a speed test using a laptop at the end of the cable feeding the YouView box.  With i-player speedtest got 10 and 20 Mb/s and other speedtest sites gave a minimum of 5 Mb/s even at the busiest internet time in the early evening.  The YouView box is not directly connected to the BT Hub, but comes through a 100 Mb/s Netgear Ethernet switch.  When we've had problems, nothing else has been active on the network.  I don't believe the problem is anything to do with the local setup.  It seems to be something to do with the BT server or where ever the C4/C5 streaming is coming from.
    Our TV is a Sony Bravia which does Internet TV.  The BBC i-player is faultless even on HD setting except occasionally at the busiest time but always runs at SD.  Five on Demand also runs perfectly.
    We signed up for BT YouView mainly because we wanted STV and C4 on demand which the Sony service doesn't provide.  Sadly the BT service has failed to provide exactly the thing we wanted.
    I noted another forum thread commented that the box hangs up.  I've had that too, and of course if you are watching live TV through it then the picture disappears because the box is taking the digital signal and processing it so you can pause live TV.  The only way to recover, it seems, if this happens is to switch the box off with the back panel switch and reboot.
    Am I alone with the C4/C5 problem or is there a solution?
    Solved!
    Go to Solution.

    Just following-up on this posting from a week or two ago and another a few days later about the problems with catch-up TV.  We were disappointed with the lack of service, but as we can get most of the catch-up we want on the Sony Bravia TV, hadn't pursued it with BT perhaps hoping things would improve.
    Got a phone call last week from BT asking if we'd been able to set up the YouView Box OK, which we had.  Mentioned the unsatisfactory service.  She immediately put me through to the BT technical call centre in India where I spoke to guy called Rajiv or something like that.  Asked a few questions and then asked me to switch off the YouView Box (back panel switch) and do a hard-reset on the Homehub Router.  Once this had been done, and the YouView box switched back on.  The service ran fine and has done so since.  I don't know if Rajiv did anything in the network or whether this is just some problem (he called it a "glitch") in the router/YouView box.  Funny that that the speedtest and streaming to the Sony TV works OK.
    He phoned back a couple of days later to see if we'd had any further problems.  Overall good service.  It would be interesting to know from a technical point of view what the problem was and how it was solved.  It shouldn't be necessary to reset boxes in this way.

  • Apple TV and iTunes problem - Different Twist

    I, too, can no longer get Apple TVs to show up in my iTunes device list.
    It DID work until last week when I downloaded two movies. They ATVs (three of them) got stuck in syncing, and were still "syncing" four days later. I quit the app, restarted it, and now all the ATVs are gone.
    The twist is, the ATVs DO show up on my MBP and another iMac on the same local network. Just not on my 27 inch iMac.
    I deleted (correctly and completely) iTunes and reinstalled - no success.
    I created a new (clean) user account - no success.
    I wiped the hard drive clean and reinstalled the software - no success.
    This HAS to be a hardware problem with the iMac.
    Any other ideas or observations or suggestions?

    cjaubert wrote:
    Question: Do you mean you removed the AppleTv from the list in iTunes or the iTunes library from the list in AppleTV Settings>Computers?
    Answer: It disappeared from iTunes and couldn't be deleted. I disconnected/deleted from ATV's settings.
    OK, good that lets you add the new library to AppleTV
    Question: New user account on the computer or new iTunes account added to AppleTV?
    Answer: On the iMac. I AM able to connect another Mac's iTunes library to the ATV and sync it. I just can't add or sync THIS one.
    You can only sync a single library with AppleTV
    Therest are shared/streaming libraries.
    Question: Did you have to set them up in AppleTV again or were they sharing libraries always known to appleTV?
    Answer: They appeared in the other computers iTunes device lists, saying "Apple TV click to set up" - just as they do at this very minute.
    Ah ok, you haven't actually set them up on those machines.
    I would turn those off just in case they're interfering with the one you want to sync being allowed a slice of the cake.
    Question: If you'd factory restored AppleTV you would have to set these up again on AppleTV.
    Answer: I don't understand, but, making an assumption, when I reset the ATV, I downloaded the update, went to connect to the network, and that connection request was received by all Macs on the network (Apple TV click to set up) except the iMac.
    I've never had my other macs turned on when trying to add an AppleTV - it's possible they could be causing problems by catching the request for th e5 digit code before the reset computer.
    Question: Why both?
    Answer: Just for a belt and suspenders - I was troubleshooting.
    Question: Do you have 2 separate local networks? If they do not see each other this could be the problem - try both individually if you haven't.
    Answer: No, I have only one. And, the iMac can see the other computers, mount them, etc., and vice versa. The ONLY apparent network problem is the ATV/iTunes/iMac problem described here.
    I hope I am less confusing now?
    Yes, getting clearer!
    Do you have any kind of extra firewall/security software on the affected machine eg Little Snitch or something like that?

  • Problems with overage charges and making account changes on line

    I have quite a bit of history involving my attempts to resolve the problem of catching my account before it goes over the minutes allowed and making the changes on line (to cut down on call volume) to change my account to raise the minutes allowed for that billing cycle.  I was given one reason why it didn't work the first time (I didn't print out my confimation proving I made the changes - bit the bullet and paid those charges) and so the second time wanting to avoid the problem from the first time I made sure I printed out my confirmation.  The confirmation had an effective date of change of 07/19/2012 the day I was informed I was nearing my allowed minutes.  There were only 4 or 5 maximum days left in that billing cycle so I wanted to nip the problem in the bud and make the changes to my account to be made "that" day.  My confirmation said the changes were effective 07/19/2012.  In plently of time before that billing cycle ended.  Again I was told I did something wrong.  This time I'm holding my confirmation in my hand even as the person is telling me again I did it wrong.  The purpose Verizon wants it's customers to use the available on-line option is to cut down on their call volume.  I didn't go to school to get the knowledge apparantly needed to perform these particular tasks in a manner that is acceptable to Verizon.  Has anyone else had problems with trying to fix their problems themselves using Verizons "helpfull" on-line choice?

    I have an explanation for you by what was meant by "you did it wrong."
    When you make a change effective the date you are requesting it and not at the start or end of your billing cycle, your minute usage for that month is pro-rated.
    For example, you say you made a change, because you were nearing your allowance limit, on 7/19/2012 and wanted it effective that day with 5 days left in the billing cycle. Lets assume that your allowance is 700 minutes/month and you were at 675 minutes for that month(still under your monthly allowance). If you make a change effective with 5 days left in your billing cycle to the 1400 minute/month allowance, your allowance for the 1st 25 days of your cycle will have been pro-rated to (25/30) * 700 = 583 minutes. This would mean you would have already had an overage of 92 minutes for the 1st 25 days of the month. Additionally, you would have a pro-rated allowance to use the last 5 days of (5/30) * 1400 = 233 minutes. This is how the pro-rating works when you make a change effective during the middle of your billing cycle.
    What you need to do next time to avoid these overage charges is to make the change effective at the beginning of your current billing cycle. So if you had made the change on 7/19/2012, but your billing cycle ended on 7/24/2012(5 days later), you should have made the change effective at the beginning of your current billing cycle, or 6/24/2012. This is called backdating the change. In this instance, you would have received a credit on you account for the cost of the 700 minute plan and been charged the full amount for the 1400 minute plan on your next bill, which I believe is a net additional charge of $10 and you would have had the use of 1400 minutes for throughout the entire month. In this example, you would not have had any overage with your 675 minutes during the 1st 25 days of your cycle and would have been able to use 725 minutes over the last 5 days of your billing cycle. This is much better than the overage charge you would receive with 92 overage minutes @ $0.45/minute = $41.40.
    I hope this explains it.

  • Problem in sending mail using java mail api

    This is the pogram I am using as of now to send a mail to yahoo id.
    import javax.mail.*;
    import javax.mail.internet.*;
    public class SendingMail2
    public SendingMail2()
    try
    String from = "ravikiran_sunrays";
    String to = "[email protected]";
    String subject = "the subject u wanna send ";
    String cc="[email protected]";
    String bcc="[email protected]";
    String text="the matter that u wanna send ";
    java.util.Properties prop = System.getProperties();
    prop.put("mail.smtp.host","mail.yahoo.com");
    //prop.put("http.proxyHost",System.getProperty("http.proxyHost"));
    //prop.put("http.proxyPort","8080");
    //prop.put("http.proxyPort",System.getProperty("http.proxyPort"));
    //prop.put("http.proxyHost","172.19.48.201");
    //System.getProperties().setProperty("http.proxyPort","8080");
    //System.getProperties().setProperty("http.proxyHost","172.19.48.201");
    Session ses = Session.getInstance(prop,null);
    MimeMessage message = new MimeMessage(ses);
    try
    Address fromAddress = new InternetAddress(from);
    message.setFrom(fromAddress);
    message.setSubject(subject);
    Address[] toAddress = InternetAddress.parse(to);
    Address[] cc_address=InternetAddress.parse(cc);
    Address[] bcc_address=InternetAddress.parse(bcc);
    message.setRecipients(Message.RecipientType.TO,toAddress);
    message.setRecipients(Message.RecipientType.CC,cc_address);
    message.setRecipients(Message.RecipientType.BCC,bcc_address);
    message.setSentDate(new java.util.Date());
    message.setText(text);
    Transport.send(message);
    System.out.println("Mail Successfully Sent");
    catch(Exception e)
    System.out.println("Problem " + e);
    catch(Exception e)
    System.out.println("Problem " + e);
    public static void main(String[] args)
    SendingMail2 sendingMail2 = new SendingMail2();
    This is the exception I am getting when I try 2 execute that program.
    avax.mail.SendFailedException: Sending failed;
    nested exception is:
         javax.mail.MessagingException: Unknown SMTP host: mail.yahoo.com;
    nested exception is:
         java.net.UnknownHostException: mail.yahoo.com

    listen buddy
    this is a class i made it is easy to understand it sends mails and check inbox just adduser from telnet with remote manager in james create the three accounts i am using and then use this class and its methods
    also the next class that contains the mails test my class and what i am saying
    import java.io.*;
    import java.util.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    public class MailClient
    extends Authenticator
    public static final int SHOW_MESSAGES = 1;
    public static final int CLEAR_MESSAGES = 2;
    public static final int SHOW_AND_CLEAR =
    SHOW_MESSAGES + CLEAR_MESSAGES;
    protected String from;
    protected Session session;
    protected PasswordAuthentication authentication;
    public MailClient(String user, String host)
    this(user, host, false);
    public MailClient(String user, String host, boolean debug)
    from = user + '@' + host;
    authentication = new PasswordAuthentication(user, user);
    Properties props = new Properties();
    props.put("mail.user", user);
    props.put("mail.host", host);
    props.put("mail.debug", debug ? "true" : "false");
    props.put("mail.store.protocol", "pop3");
    props.put("mail.transport.protocol", "smtp");
    session = Session.getInstance(props, this);
    public PasswordAuthentication getPasswordAuthentication()
    return authentication;
    public void sendMessage(
    String to, String subject, String content)
    throws MessagingException
    System.out.println("SENDING message from " + from + " to " + to);
    System.out.println();
    MimeMessage msg = new MimeMessage(session);
    msg.addRecipients(Message.RecipientType.TO, to);
    msg.setSubject(subject);
    msg.setText(content);
    Transport.send(msg);
    public void checkInbox(int mode)
    throws MessagingException, IOException
    if (mode == 0) return;
    boolean show = (mode & SHOW_MESSAGES) > 0;
    boolean clear = (mode & CLEAR_MESSAGES) > 0;
    String action =
    (show ? "Show" : "") +
    (show && clear ? " and " : "") +
    (clear ? "Clear" : "");
    System.out.println(action + " INBOX for " + from);
    Store store = session.getStore();
    store.connect();
    Folder root = store.getDefaultFolder();
    Folder inbox = root.getFolder("inbox");
    inbox.open(Folder.READ_WRITE);
    Message[] msgs = inbox.getMessages();
    if (msgs.length == 0 && show)
    System.out.println("No messages in inbox");
    for (int i = 0; i < msgs.length; i++)
    MimeMessage msg = (MimeMessage)msgs;
    if (show)
    System.out.println(" From: " + msg.getFrom()[0]);
    System.out.println(" Subject: " + msg.getSubject());
    System.out.println(" Content: " + msg.getContent());
    if (clear)
    msg.setFlag(Flags.Flag.DELETED, true);
    inbox.close(true);
    store.close();
    System.out.println();
    ====================================
    testing this class
    =======================================
    public class JamesConfigTest
    public static void main(String[] args)
    throws Exception
    // CREATE CLIENT INSTANCES
    MailClient redClient = new MailClient("red", "localhost");
    MailClient greenClient = new MailClient("green", "localhost");
    MailClient blueClient = new MailClient("blue", "localhost");
    // CLEAR EVERYBODY'S INBOX
    redClient.checkInbox(MailClient.CLEAR_MESSAGES);
    greenClient.checkInbox(MailClient.CLEAR_MESSAGES);
    blueClient.checkInbox(MailClient.CLEAR_MESSAGES);
    Thread.sleep(500); // Let the server catch up
    // SEND A COUPLE OF MESSAGES TO BLUE (FROM RED AND GREEN)
    redClient.sendMessage(
    "blue@localhost",
    "Testing blue from red",
    "This is a test message");
    greenClient.sendMessage(
    "blue@localhost",
    "Testing blue from green",
    "This is a test message");
    Thread.sleep(500); // Let the server catch up
    // LIST MESSAGES FOR BLUE (EXPECT MESSAGES FROM RED AND GREEN)
    blueClient.checkInbox(MailClient.SHOW_AND_CLEAR);
    =======================================================
    it suppose to print this
    Clear INBOX for red@localhost
    Clear INBOX for green@localhost
    Clear INBOX for blue@localhost
    SENDING message from red@localhost to blue@localhost
    SENDING message from green@localhost to blue@localhost
    Show and Clear INBOX for blue@localhost
    From: green@localhost
    Subject: Testing blue from green
    Content: This is a test message
    From: red@localhost
    Subject: Testing blue from red
    Content: This is a test message
    thanks a lot
    but i need ur help plzzzzzzzzzzzz
    i can create account from telnet
    but how i can create a new account from java .. a jsp page that i made to create a new account on the server
    plzzzzzzzz help me
    bye

  • "catch is unreachable" compiler error with java try/catch statement

    I'm receiving a compiler error, "catch is unreachable", with the following code. I'm calling a method, SendMail(), which can throw two possible exceptions. I thought that the catch statements executed in order, and the first one that is caught will execute? Is their a change with J2SE 1.5 compiler? I don't want to use a generic Exception, because I want to handle the specific exceptions. Any suggestions how to fix? Thanks
    try {
    SendMail(....);
    } catch (MessagingException e1) {
    logger.fine(e1.toString());
    } catch (AddressException e2) {
    logger.fine(e2.toString());
    public String SendMail(....) throws AddressException,
    MessagingException {....                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    I found the problem:
    "A catch block handles exceptions that match its exception type (parameter) and exception types that are subclasses of its exception type (parameter). Only the first catch block that handles a particular exception type will execute, so the most specific exception type should come first. You may get a catch is unreachable syntax error if your catch blocks do not follow this order."
    If I switch the order of the catch exceptions the compiler error goes away.
    thanks

  • Problem in executing Linux command from Java Programme.

    hi everybody,
    can anybody help me to solve one problem i have.
    i want to capture the output of linux command "grep" in my java programme.but it is not working properly .(maybe this sub-process doesn't have permission to read files)
    here is my code and corresponding outputs.
    import java.io.*;
    public class BSearch
    public static void main(String kj[])
    try
    Runtime rt=Runtime.getRuntime();
    String command="grep \"hello\" -r /usr/MyDir ";               
    Process rtProc=rt.exec(command);          
    InputStream is=rtProc.getInputStream();
    BufferedReader br =new BufferedReader(new InputStreamReader(is));     
    String line =null;
    while((line=br.readLine()) != null)
    System.out.println(br.readLine());
    br.close();
    catch(Exception e)
    System.err.println("Error in command "+e);               
    it finds "hello" pattern only in BSearch.class file although if i fire this command on LINUX prompt it
    shows all the files in /usr/MyDir which contain "hello" pattern.
    java programme output :
    Binary file /usr/MyDir/BSearch.class matches.
    linux command output :
    /usr/MyDir/one.txt: hello sdfs
    Binary file /usr/MyDir/BSearch.class matches.
    /usr/MyDir/two.txt: kjsdf hello sdfsdf
    will anybody help me solve this problem.

    It may be a Problem of Catching the Echoes back from the Processes...I have a Program which Captures the Echoes..see if it works
    import java.beans.PropertyChangeEvent;import java.beans.PropertyChangeListener;import java.beans.PropertyChangeSupport;import java.lang.ref.WeakReference;/** * Implements a proxy property change listener using a weak reference to avoid memory locking that would occur if it * was a strong reference. To understand this, we hve to understand that the property change listeners themselves are * hilding onto panels and other objects with strong java references. If the panel goes away while we are viewing an * object, we have a circular emory hold situation where the panel cant be collected because it has ahold of the * property and the property cannot because it has ahold of the pane. If we use weak references instead, then the hard * link between the listener and the producer is softened to almost nothing. */public class WeakPropertyChangeListener implements PropertyChangeListener {  /**   * A poperty change support object is included here so that the listener can remove   * himself from the listeners if the reference internally goes to null.   */  private PropertyChangeSupport pcs = null;  /** Holds the weak reference to the real listener. */  private WeakReference weakRef = null;  /**   * Constructs a new Proxy object for the given support and listener.   * @param pcs The property change support that this object will be using.   * @param pcl The real listener.   */  public WeakPropertyChangeListener(PropertyChangeSupport pcs, PropertyChangeListener pcl) {    if (pcs == null) throw new NullPointerException("pcs");    if (pcl == null) throw new NullPointerException("pcl");    this.pcs = pcs;    weakRef = new WeakReference(pcl);  } /** @see <{PropertyChangeListener}> */ public void propertyChange(PropertyChangeEvent changeEvent) {    Object referrant = weakRef.get();    if (referrant == null) {      pcs.removePropertyChangeListener(this);    } else {      ((PropertyChangeListener)referrant).propertyChange(changeEvent);    } } /** Returns true for comparison to referrant or this. */ public boolean equals(Object obj) {    if (obj instanceof WeakPropertyChangeListener) return super.equals(obj);    else if (obj != null)return obj.equals(weakRef.get());    else return false;  }}// snipet public void addPropertyChangeListener(PropertyChangeListener listener) {    this.propertyChangeSupport.addPropertyChangeListener(      new WeakPropertyChangeListener(this.propertyChangeSupport, listener));  } public void removePropertyChangeListener(PropertyChangeListener listener) {    this.propertyChangeSupport.removePropertyChangeListener(listener);  }

  • A small problem in DES

    I am a beginner to write an encrypt program
    I write a simple program to choose a file and use DES to encrypt.
    It can' t decrypt
    I don't know why
    The following is my program
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.filechooser.*;
    import javax.crypto.*;
    import javax.crypto.spec.*;
    import java.security.*;
    import java.security.spec.*;
    import java.util.*;
    public class encrypt_test extends JFrame
    private File openfile;
    private KeyGenerator kg;
    private SecretKey secretKey,secretKey2;
    private Cipher desCipher;
    public encrypt_test()
    super("encrypt_homework");
    Container c = getContentPane();
    final JTextArea readmearea = new JTextArea(15,30);
    readmearea.setEditable(false);
    JScrollPane scroll = new JScrollPane(readmearea);
    JPanel buttonpanel = new JPanel();
    JButton open = new JButton("Open");
    final JFileChooser fc = new JFileChooser();
    open.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent evt)
         int n = fc.showOpenDialog(encrypt_test.this);
         if( n == JFileChooser.APPROVE_OPTION)
         openfile = fc.getSelectedFile();
         readmearea.append("OpenFileis: "+openfile.getName()+"\n");
         else
         eadmearea.append("To cancel open file");
    buttonpanel.add(open);
    JButton encrypt = new JButton("Encrypt");
    encrypt.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent evt)
         try
         kg = KeyGenerator.getInstance("DES");
         secretKey = kg.generateKey();
         secretKey2 = secretKey;
         desCipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
         desCipher.init(Cipher.ENCRYPT_MODE, secretKey);
         FileOutputStream fos = new FileOutputStream(openfile);
         BufferedOutputStream bos = new BufferedOutputStream(fos);
         CipherOutputStream cos = new CipherOutputStream(bos,desCipher);
         ObjectOutputStream oos = new ObjectOutputStream(cos);
         oos.writeObject(openfile);
         oos.flush();
         oos.close();
         readmearea.append("Encrypt Success"+"\n");
         catch(NoSuchAlgorithmException e)
         System.err.println("Invalid algorithm: " + e);
         catch(NoSuchPaddingException e)
         System.err.println("Padding problem: " + e);
         catch(InvalidKeyException e)
         System.err.println("Invalid key: " + e);
         catch(IOException e)
         System.err.println("I/O Problem: " + e);
    buttonpanel.add(encrypt);
    JButton decrypt = new JButton("Decrypt");
    decrypt.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent evt)
         try
         desCipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
         desCipher.init(Cipher.DECRYPT_MODE, secretKey2);
         FileOutputStream fos = new FileOutputStream(openfile);
         BufferedOutputStream bos = new BufferedOutputStream(fos);
         CipherOutputStream cos = new CipherOutputStream(bos,desCipher);
         ObjectOutputStream oos = new ObjectOutputStream(cos);
         oos.writeObject(openfile);
         oos.flush();
         oos.close();
         readmearea.append("Decrypt Success"+"\n");
         catch(NoSuchAlgorithmException e)
         System.err.println("Invalid algorithm: " + e);
         catch(NoSuchPaddingException e)
         System.err.println("Padding problem: " + e);
         catch(InvalidKeyException e)
         System.err.println("Invalid key: " + e);
         catch(IOException e)
         System.err.println("I/O Problem: " + e);
    buttonpanel.add(decrypt);
    c.add(scroll,BorderLayout.CENTER);
    c.add(buttonpanel,BorderLayout.SOUTH);
    public static void main(String[] args )
    encrypt_test app = new encrypt_test();
    app.addWindowListener(new WindowAdapter()
    public void windowClosing(WindowEvent evt)
    System.exit(0);
    app.setSize(300,200);
    app.setVisible(true);
    }

    this is my decrypt body
    the result is that plaintext is null
    I don't know why
    desCipher2 = Cipher.getInstance("DES/ECB/PKCS5Padding");
    desCipher2.init(Cipher.DECRYPT_MODE,key2);
    FileInputStream in = new FileInputStream(openfile);
    File testfile = new File("test100.txt");
    FileOutputStream fileout = new FileOutputStream(testfile);
    CipherOutputStream out = new CipherOutputStream(fileout,desCipher2);
    ObjectOutputStream oos = new ObjectOutputStream(out);
    byte[] buffer = new byte[kBufferSize];
    int length;
    while((length = in.read(buffer)) != -1)
    oos.write(buffer,0,length);
    oos.flush();
    in.close();
    oos.close();

  • Problem inputting a SecretKey object into a KeyStore

    i am having some problem storing my secretkey object in a key store, i keep getting the error shown below
    cannot resolve symbol - class SecretKeyEntry.
    the whole class is shown below. i have tried to import the SecretKeyEntry class but i still get an error. can anybody help.
    import java.io.*;
    import javax.crypto.*;
    import javax.crypto.spec.*;
    import java.security.*;
    import java.security.KeyStore.*;
    //import java.security.KeyStore.SecretKeyEntry;
    import java.security.spec.*;
    import java.util.*;
    public class Encrypt {
    public static void main(String args[]) {
    File desFile = new File("Saving a text document as an image file.doc");
    // Create data to encrypt
    Map map = new TreeMap(System.getProperties());
    int number = map.size();
    try {
    // Create Key
    KeyGenerator kg = KeyGenerator.getInstance("DES");
    SecretKey secretKey = kg.generateKey();
    // key store code start
    KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
    char[] password = {'f','r','a','n','k'};
    System.out.println("my password" + password.toString());
    ks.load(null, password);
    // save my secret key
    KeyStore.SecretKeyEntry skEntry = new KeyStore.SecretKeyEntry(mySecretKey);
    ks.setEntry("secretKeyAlias", skEntry, password);
    //keystore code end
    // Create Cipher
    Cipher desCipher =
    Cipher.getInstance("DES/ECB/PKCS5Padding");
    desCipher.init(Cipher.ENCRYPT_MODE, secretKey);
    // Create stream
    FileOutputStream fos = new FileOutputStream(desFile);
    BufferedOutputStream bos = new BufferedOutputStream(fos);
    CipherOutputStream cos = new CipherOutputStream(bos,
    desCipher);
    ObjectOutputStream oos = new ObjectOutputStream(cos);
    // Write objects
    oos.writeObject(map);
    oos.writeInt(number);
    oos.flush();
    oos.close();
    } catch (NoSuchPaddingException e) {
    System.err.println("Padding problem: " + e);
    } catch (NoSuchAlgorithmException e) {
    System.err.println("Invalid algorithm: " + e);
    } catch (InvalidKeyException e) {
    System.err.println("Invalid key: " + e);
    } catch (KeyStoreException e) {
    System.err.println("Problem getting Keystore instance" + e);
    } catch (IOException e) {
    System.err.println("I/O Problem: " + e);
    } catch (Exception e) {
    System.err.println("All other exceptions" + e);
    } finally {
    if (desFile.exists()) {
    //desFile.delete();
    }

    You need to change your setEntry() line to this:ks.setEntry("secretKeyAlias", skEntry, new KeyStore.PasswordProtection(password));You also need to insure that you're running under 1.5 - this API didn't exist before that. If you're picking up a 1.4 JVM/libs, it would explain your compilation error.
    Grant

  • FPGA module unzip problem

    I downloaded the FPGA module into a controler of a PXI, running XP.  When I tried to unzip it, the upzip operation would fail everytime.  What is causing this?  Is there some kind of requirement to unzip this?  Harddrive size requirement?
    Kudos and Accepted as Solution are welcome!
    Solved!
    Go to Solution.

    Thanks for helping.  I found out what was the problem.  I downloaded the FPGA module through the link below.  When I tried to unzip it, I would use the default path.  Apparently, the default path has a space at the end of its 2nd folder, counting from the end of the path.  This is a small bug from NI, but it needs to be fixed.  It is a hard problem to catch, since I didn't expect something like that to happen. 
    https://lumen.ni.com/nicif/us/evallvuser/content.xhtml
    Kudos and Accepted as Solution are welcome!

Maybe you are looking for

  • How to handle the exception in AWT-EventQueue-0?

    This is my code: import javax.swing.JFrame; public class MainFrame extends JFrame {      public MainFrame(){           init();      public void init(){           setSize(100,100); import java.awt.event.ActionEvent; import java.awt.event.ActionListene

  • Missing facility: graphic channel mixer

    Hi Guys, I miss a graphic channel mixer so that I can reduce channel separation in problem zones, primarily the bass range when handling vinyl and shellack, but there may also be benefits for similar processing in the treble range. Kind regards Peter

  • Dbms_scheduler.add_job_email_notification

    Hi, With our latest upgrade to Oracle 11g R2 Database, I tried to generate job email notification using the new feature dbms_sheduler.add_job_email_notification for the JOB_STARTED,JOB_STOPPED,JOB_FAILED,JOB_BROKEN,JOB_COMPLETED and JOB_DISABLED even

  • Encapsulation dot1q any second any on me3600x

    Hi, we recieve a number of downstream hand-offs that are delivered as SVID/CVID ccts.  There are mixture of data, and VOIP subscribers, the only way to tell the different type of subscribers is that the all voip services are marked as cos 4.  All dat

  • Splitting single idoc into multiple xml's

    Hello, My requirement is such that, i need to split an custom IDoc into three xml which will be picked up by MDM, as i am new to PI 7.1 kindly guide me through the process. and the second requirement is, i need to map the same custom IDoc into three