Simple Program - Day Number

Hi, I am trying to pick up java...and need help with a program
I want to be able to figure out the number of days into a year from a date --
for example - user input -
year - 2001
month - 01
day 01
the output would be 1...
and for dec. 31, 366 (depending on leap year)
I am trying to do it without cal methods...basically just joptionpane if anything
Thanks so much!
Jason

This is based on some old C logic.
public class DayOfYear
    public static void main(String[] args)
        int year = Integer.parseInt(args[0]);
        int mo = Integer.parseInt(args[1]) - 1;
        int day = Integer.parseInt(args[2]);
        int leap = 0;
        int[][] mos = {
            {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
            {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};
        if((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
           leap = 1;
        for(int n = 0; n < mo; n++)
            day += mos[leap][n];
        System.out.println("days = " + day);
}

Similar Messages

  • JMS: simple program (urgent please)

    I am quite new with the JMS. I am trying to have a simple program running in order to start from it towards the application I want to build.
    I tried to run the sample program below:
    package chat;
    import javax.jms.*;
    import javax.naming.*;
    import java.io.*;
    import java.io.InputStreamReader;
    import java.util.Properties;
    public class Chat implements javax.jms.MessageListener {
    private TopicSession pubSession;
    private TopicSession subSession;
    private TopicPublisher publisher;
    private TopicConnection connection;
    /* Constructor. Establish JMS publisher and subscriber */
    public Chat() throws Exception {
    // Obtain a JNDI connection
    Properties env = new Properties();
    // ... specify the JNDI properties specific to the vendor
    InitialContext jndi = new InitialContext(env);
    // Look up a JMS connection factory
    TopicConnectionFactory conFactory =
    (TopicConnectionFactory) jndi.lookup("TopicConnectionFactory");
    // Create a JMS connection
    TopicConnection connection =
    conFactory.createTopicConnection();
    // Create two JMS session objects
    TopicSession pubSession =
    connection.createTopicSession(false,
    Session.AUTO_ACKNOWLEDGE);
    TopicSession subSession =
    connection.createTopicSession(false,
    Session.AUTO_ACKNOWLEDGE);
    // Look up a JMS topic
    Topic chatTopic = (Topic) jndi.lookup("anytopic");
    // Create a JMS publisher and subscriber
    TopicPublisher publisher =
    pubSession.createPublisher(chatTopic);
    TopicSubscriber subscriber =
    subSession.createSubscriber(chatTopic);
    // Set a JMS message listener
    subscriber.setMessageListener(this);
    // Intialize the Chat application
    set(connection, pubSession, subSession, publisher);
    // Start the JMS connection; allows messages to be delivered
    connection.start();
    /* Initialize the instance variables */
    public void set(TopicConnection con, TopicSession pubSess,
    TopicSession subSess, TopicPublisher pub) {
    this.connection = con;
    this.pubSession = pubSess;
    this.subSession = subSess;
    this.publisher = pub;
    /* Receive message from topic subscriber */
    public void onMessage(Message message) {
    try {
    TextMessage textMessage = (TextMessage) message;
    String text = textMessage.getText();
    System.out.println(text);
    } catch (JMSException jmse) {
    jmse.printStackTrace();
    /* Create and send message using topic publisher */
    protected void writeMessage(String text) throws JMSException {
    TextMessage message = pubSession.createTextMessage();
    publisher.publish(message);
    /* Close the JMS connection */
    public void close() throws JMSException {
    connection.close();
    /* Run the Chat client */
    public static void main(String[] args) {
    try {
    Chat chat = new Chat();
    // Read from command line
    BufferedReader commandLine = new
    java.io.BufferedReader(new
    InputStreamReader(System.in));
    // Loop until the word "exit" is typed
    while (true) {
    String s = commandLine.readLine();
    if (s.equalsIgnoreCase("exit")) {
    chat.close(); // close down connection
    System.exit(0); // exit program
    } else {
    chat.writeMessage(s);
    } catch (Exception e) {
    e.printStackTrace();
    But at the line
    �TopicConnectionFactory conFactory =
    (TopicConnectionFactory) jndi.lookup("TopicConnectionFactory");�
    I got this exception:
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
         at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)
         at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
         at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)
         at javax.naming.InitialContext.lookup(InitialContext.java:347)
         at chat.Chat.<init>(Chat.java:24)
         at chat.Chat.main(Chat.java:94)
    I realize that the problem is in the jndi setup. But, the problem is that I do not know where to go now and what should I do. I do not know how can I get the jndi.properties file and where and how to put it.
    Please, kindly advise from your experience. I would appreciate clear steps to have this program running properly. Otherwise, if you do have a sample program that is already running, please provide it to me.

    Thank you for your prompt reply.
    I tried another example.
    package test;
    javax.jms.*;
    import javax.naming.*;
    public class SimpleTopicPublisher { /** * Main method. * * @param args the topic used by the example and, * optionally, the number of messages to send */
    public static void main(String[] args) {
    String topicName = null;
    Context jndiContext = null;
    TopicConnectionFactory topicConnectionFactory = null;
    TopicConnection topicConnection = null;
    TopicSession topicSession = null;
    Topic topic = null;
    TopicPublisher topicPublisher = null;
    TextMessage message = null;
    final int NUM_MSGS;
    // if ((args.length < 1) || (args.length > 2)) {
    // System.out.println("Usage: java " + "SimpleTopicPublisher " + "[]");
    // System.exit(1);
    topicName = new String("MyTopic");
    System.out.println("Topic name is " + topicName);
    if (args.length == 2) {
    NUM_MSGS = (new Integer(args[1])).intValue();
    } else {
    NUM_MSGS = 1;
    /* * Create a JNDI API InitialContext object if none exists * yet. */
    try {
    jndiContext = new InitialContext
    } catch (NamingException e) {
    System.out.println("Could not create JNDI API " + "context: " +
    e.toString());
    e.printStackTrace();
    System.exit(1);
    /* * Look up connection factory and topic. If either does * not exist, exit. */
    try {
    topicConnectionFactory = (TopicConnectionFactory) jndiContext.
    lookup("TopicConnectionFactory");
    topic = (Topic) jndiContext.lookup(topicName);
    } catch (NamingException e) {
    System.out.println("JNDI API lookup failed: " + e.toString());
    e.printStackTrace();
    System.exit(1);
    /* * Create connection. * Create session from connection; false means session is * not transacted. * Create publisher and text message. * Send messages, varying text slightly. * Finally, close connection. */
    try {
    topicConnection = topicConnectionFactory.createTopicConnection();
    topicSession = topicConnection.createTopicSession(false,
    Session.AUTO_ACKNOWLEDGE);
    topicPublisher = topicSession.createPublisher(topic);
    message = topicSession.createTextMessage();
    for (int i = 0; i < NUM_MSGS; i++) {
    message
    .setText("This is message " + (i + 1));
    System.out.println("Publishing message: " + message.getText());
    topicPublisher.publish(message);
    } catch (JMSException e) {
    System.out.println("Exception occurred: " + e.toString());
    } finally {
    if (topicConnection != null) {
    try {
    topicConnection.close();
    } catch (JMSException e) {}
    It is mentioned in SUN JMS tutorial that "When you use the J2EE SDK 1.3.1, your JMS provider is the SDK. " So I am using that and I did the follwoing:
    --start the J2EE server as follows:
    j2ee -verbose
    Then I created the adminstrated object:
    j2eeadmin -addJmsDestination MyTopic topic
    But still getting this error:
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    So now where is the error?
    Thank you in advance

  • How can i make simple program to match colors ?(photos taken by camera)

    how can i make simple program to match colors ?(photos taken by camera)

    Hi khaledyr,
    use a "random number" and compare for ">0.5" to get a (1 or 0) signal
    What exactly are you searching for?
    - Hints for choosing hardware?
    - How to output voltage or relais signals?
    - Help on using DAQ(mx)?
    - Help on generating (boolean) waveforms?
    Message Edited by GerdW on 04-16-2010 08:15 AM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Does anyone have a simple program that will return the size of a file

    Does anyone have a simple program that will return the size of a file?

    I quite hate it when I receive the incorrect amount of yoctocandela per metre squared. Swarthy people
    can't properly convert poundal feet to barleycorn; throws off the whole conversion! Aaah, you get what
    you paid for.I recognize those figures; you've got your outsourced file sizes from Zanzibar; admit it! I always apply
    the scientific approach when I've got file sizes back from Zanzibar: I simply divide those numbers by
    pi (very scientific) and drop the eleven (ueber scientific, because 11 is prime even when looked upon
    as a binary number) least significant bits. And remember: never compare two floating point numbers
    for equality. (<--- that's a free tip)
    Jos ;-)

  • Why can't there be a simple program to setup remote file sharing?

    If someone wants to take a crack at getting my Time Capsule available remotely (off network over internet), I would appreciate it.
    I am a graphic designer and use the other side of my brain. DNS, static IP, MAC address etc is very confusing.
    I purchased a neat little app called Connect360 for Mac that automatically configures music/video sharing to Xbox360 from MacBook Pro. Evrything is automatic. Brilliant. If someone could do that to configure internet file sharing, it would be worth $$$$$$.
    Thanks

    You cannot do a simple program with the multiplicity of internet connections, modem type, ISP types, authentication types. Also you notice that Apple decided everything should now happen from the cloud, so cancelled the mobileme service which did offer easier setup for something that is far more limited, at least for now.
    Also please note there are fridge mechanics who fix fridges and car mechanics who fix cars. Photographers who make a living taking better photos than I can, and computer technicians who do network setups. If you don't fix your car or the washing machine.. why do you need to fix your internet networking?? Pay someone to do it.. but Steve said computers are easy and you got a false impression that everything should just plug together and work.. well it doesn't. Find a tame Computer tech and let him/her carry that part of your business. Spend your time doing what earns you money instead of in frustration at fixing the fridge. (Being symbolic of the computer network).
    It is rather like when I (a computer technician) dabble in graphic design.. I do, and you laugh at the results.. !!
    Please note I no longer work in that field because the pay is miserable, the customers ring up day and night and scream at you that the network is down and it is all your fault, and want you to spend an hour on the phone helping them. No service fee of course. You should on the basis of a single job, help connect their computer to the printer over the phone for an hour, rather than pay you a service call. Since computers are easy and you should just donate your time and life really to helping them do what Steve and Bill said was so easy.

  • Day link - want Item to contain day number from calendar

    I'm a bit stymied here.
    Using the calendar, I would like to add a branch to a page based on the DAY of the calendar that the user clicks on. For example, if the calendar is on the screen, and the user clicks on day number 15, then I would like that "15" passed to the page that the user is sent to.
    Being a little more specific:
    Page 1 is a calendar page. When the user clicks on a day number in the calendar, I want it to branch to Page 2.
    Page 2 contains a text field for the calendar day. I would like to populate this field with the day number selected on Page 1.
    I can't seem to get ApEx to do this, but it seems like an obvious feature that users would want if they're using the Day Link functionality at all.
    Can anyone help??
    thanks,
    bruce

    I just tried creating a custom calendar template. There I changed the Weekday Attributed / Day Title Format to the following:
    &lt;a href="f?p=&APP_ID.:2:&SESSION.::&DEBUG.::P2_DAY:#DD#">&lt;div class="t10DayTitle">#DD#&lt;/div>&lt;/a>
    and this worked out.
    You also need to change the
    Non-Day Title Format and
    Weekend Title Format
    the same way, in order to cover all dates.
    Denes Kubicek

  • Ideas For a Simple Program?

    I need some ideas for a simple program for a project in class. Can anyone help me?

    Import Classes
    import java.io.*;
    public class tictactoe
    Define Variables
    public static InputStreamReader ISR = new InputStreamReader(System.in);
    public static BufferedReader BFR = new BufferedReader(ISR);
    public static String BOX[][] = new String[3][3]; //Integer Arry for tictactoe box
    public static String PName; //Moving Player's Name
    public static String P1Name; //Player 1 Name
    public static String P2Name; //Player 2 Name
    public static String InputPLY; //X or O
    public static String InputStr; //Player's Input
    public static boolean BreakLoop; //Set this to true in PlayGame() to exit
    public static void main(String args[]) throws IOException
    InputPLY = "O";
    BreakLoop = false;
    ClearBOXCache();
    PrintCredits();
    System.out.println("");
    System.out.println("PLEASE ENTER PLAYER 1 NAME");
    P1Name = BFR.readLine();
    System.out.println("PLEASE ENTER PLAYER 2 NAME");
    P2Name = BFR.readLine();
    System.out.println("");
    System.out.print("\nWelcome ");
    System.out.print(P1Name);
    System.out.print(" and ");
    System.out.println(P2Name);
    System.out.println("");
    System.out.println(P1Name + " = X");
    System.out.println(P2Name + " = O");
    PlayGame();
    PrintCredits();
    BFR.readLine();
    System.exit(0);
    public static void DrawGrid()
    This function is to draw the tictactoe grid.
    System.out.println("");
    System.out.println("\t/-----------------------------\\");
    System.out.println("\t|-------- TIC TAC TOE --------|");
    System.out.println("\t|-----------------------------|");
    System.out.println("\t| | | |");
    System.out.println("\t| " + BOX[0][0] + " | " + BOX[0][1] + " | " + BOX[0][2] + " |");
    System.out.println("\t| | | |");
    System.out.println("\t|-----------------------------|");
    System.out.println("\t| | | |");
    System.out.println("\t| " + BOX[1][0] + " | " + BOX[1][1] + " | " + BOX[1][2] + " |");
    System.out.println("\t| | | |");
    System.out.println("\t|-----------------------------|");
    System.out.println("\t| | | |");
    System.out.println("\t| " + BOX[2][0] + " | " + BOX[2][1] + " | " + BOX[2][2] + " |");
    System.out.println("\t| | | |");
    System.out.println("\t\\-----------------------------/");
    public static void PrintCredits()
    This function is to print credits. Intended for startup and ending
    System.out.println("");
    System.out.println("");
    System.out.println("\t-------------------------------");
    System.out.println("\t--------- TIC TAC TOE ---------");
    System.out.println("\t-------------------------------");
    System.out.println("");
    System.out.println("\t-------------------------------");
    System.out.println("\t---- MADE BY WILLIAM CHAN! ----");
    System.out.println("\t-------------------------------");
    public static void ClearBOXCache()
    This function is to clear the BOX's cache.
    It is intended for restarting a game     
    BOX[0][0] = " ";
    BOX[0][1] = " ";
    BOX[0][2] = " ";
    BOX[1][0] = " ";
    BOX[1][1] = " ";
    BOX[1][2] = " ";
    BOX[2][0] = " ";
    BOX[2][1] = " ";
    BOX[2][2] = " ";
    public static void CheckWin(String PLYW) throws IOException
    This function is to check if a player wins
    for (int X = 0; X < 3; X++)
    if (BOX[X][0].equals(PLYW) && BOX[X][1].equals(PLYW) && BOX[X][2].equals(PLYW))
    PrintWin(PLYW);
    for (int Y = 0; Y < 3; Y++)
    if (BOX[0][Y].equals(PLYW) && BOX[1][Y].equals(PLYW) && BOX[2][Y].equals(PLYW))
    PrintWin(PLYW);
    if (BOX[0][0].equals(PLYW) && BOX[1][1].equals(PLYW) && BOX[2][2].equals(PLYW))
    PrintWin(PLYW);
    else if (BOX[0][2].equals(PLYW) && BOX[1][1].equals(PLYW) && BOX[2][0].equals(PLYW))
    PrintWin(PLYW);
    else if (!BOX[0][0].equals(" ") && !BOX[0][1].equals(" ") && !BOX[0][2].equals(" ") && !BOX[1][0].equals(" ") && !BOX[1][1].equals(" ") && !BOX[1][2].equals(" ") && !BOX[2][0].equals(" ") && !BOX[2][1].equals(" ") && !BOX[2][2].equals(" "))
    ClearBOXCache();
    System.out.println("Tie Game!");
    BFR.readLine();
    System.out.println("Game has restarted");
    public static void PrintWin(String PrintWinner) throws IOException
    This function is to print which player won
    if (PrintWinner.equals("X"))
    System.out.println(P1Name + " wins!");
    System.out.println(P2Name + " loses!");
    else if (PrintWinner.equals("O"))
    System.out.println(P2Name + " wins!");
    System.out.println(P1Name + " loses!");
    BFR.readLine();
    ClearBOXCache();
    System.out.println("Game has restarted!");
    public static void PrintInstruction(String PLYINSTR)
    This function is to give instruction to the player
    if (PLYINSTR.equals("X"))
    PName = (P1Name);
    else if (PLYINSTR.equals("O"))
    PName = (P2Name);
    System.out.println("");
    System.out.println(PName + ":");
    System.out.println("PLEASE MAKE YOUR MOVE");
    System.out.println("");
    System.out.println("TL = TOP LEFT BOX, TM = TOP MIDDLE BOX, TR = TOP RIGHT BOX");
    System.out.println("ML = MIDDLE LEFT BOX, MM = MIDDLE MIDDLE BOX, MR = MIDDLE RIGHT BOX");
    System.out.println("BL = BOTTOM LEFT BOX, BM = BOTTOM MIDDLE BOX, BR = BOTTOM RIGHT BOX");
    public static void PlayGame() throws IOException
    This function is the main game function.
    It calls other game functions.         
    Define Variables
    while(true)
    if (InputPLY.equals("O"))
    InputPLY = "X";
    else if (InputPLY.equals("X"))
    InputPLY = "O";
    while(true)
    PrintInstruction(InputPLY);
    InputStr = BFR.readLine(); //Player's move
    Check player's move
    if (InputStr.equals("TL"))
    if (BOX[0][0].equals(" "))
    BOX[0][0] = InputPLY;
    break;
    else if (InputStr.equals("TM"))
    if (BOX[0][1].equals(" "))
    BOX[0][1] = InputPLY;
    break;
    else if (InputStr.equals("TR"))
    if (BOX[0][2].equals(" "))
    BOX[0][2] = InputPLY;
    break;
    else if (InputStr.equals("ML"))
    if (BOX[1][0].equals(" "))
    BOX[1][0] = InputPLY;
    break;
    else if (InputStr.equals("MM"))
    if (BOX[1][1].equals(" "))
    BOX[1][1] = InputPLY;
    break;
    else if (InputStr.equals("MR"))
    if (BOX[1][2].equals(" "))
    BOX[1][2] = InputPLY;
    break;
    else if (InputStr.equals("BL"))
    if (BOX[2][0].equals(" "))
    BOX[2][0] = InputPLY;
    break;
    else if (InputStr.equals("BM"))
    if (BOX[2][1].equals(" "))
    BOX[2][1] = InputPLY;
    break;
    else if (InputStr.equals("BR"))
    if (BOX[2][2].equals(" "))
    BOX[2][2] = InputPLY;
    break;
    else if (InputStr.equals("RESTART"))
    ClearBOXCache();
    System.out.println("");
    System.out.println("GAME RESTARTED!");
    System.out.println("");
    break;
    else if (InputStr.equals("QUIT"))
    BreakLoop = true;
    break;
    if (BreakLoop == true)
    break;
    DrawGrid();
    CheckWin(InputPLY);
    }

  • Any ideas for a (fairly) simple program?

    Does anybody have any ideas for a fairly simple program that I could try to write (I am a fair programmer, but I'm not to creative)?

    You know, Java Game Programming for Dummies is actually a pretty good book (despite the "Dummies" part!) It is written in 1.0, but it has a "ponglet", card games, and several maze games. All the applets I've tried from them actually work (some typos in the book itself, but the CD is ok). Any of these could be "starter" code.
    Yahoo has a whole bunch of Java applet games. You could try to reproduce pieces of the games you see. (These are also interesting in the sense that you can immediately see what works in a game and what doesn't.)
    It is always fun to write little components. Cool buttons (write a nice little non-rectangular button that lights up or something), text boxes that look like digital displays, funny text labels (maybe with a weird font or with letters that jump all over the place when you mouse over them).. These don't take a whole lot of time to write, but write them well and they are very useful for your future games.
    Enjoy!
    :) jen

  • Can't make a selection of my pathes even if i have set a program change number for each one.Why is that happening?

    Hi everybody!
    I send program change messages from my midi controller and the messages are accepted by mainstage 3 as shown in the midi message window,but i can't make a selection of my pathes even if i have set a program change number for each patch.Why is that happening?
    I use a novation SL mki or a KORG Triton Le or a m-audio axiom 49 as midi controllers.The program change messages are transmitted by all the devices i mentioned above and shown as received in the midi messages window of mainstage 3.
    Has anyone the same experience?

    Hi
    Have you selected the correct device as the Program Change device and MIDI channel in the Concert Inspector?
    CCT

  • Date from Day number and year

    Dear experts,
    i have day number and year ,i wanted to identify the date
    ex: day number=203 year=2009
    date:22/07/2009
    please advice the best possible way to acheive this.
    thanks

    Florian:
    Given that the OP said his fields were VARCHAR2, and his sample data showed leading zeroes, your original solution will work as posted. If the data had been numeric, another solution would be to just reverse the order of the components.
    SQL> WITH t AS (
      2     SELECT 2009 yr, 203 day_no FROM dual union all
      3     SELECT 2006, 201 FROM dual union all
      4     SELECT 1999,  99 FROM dual union all
      5     SELECT 2000, 001 FROM dual union all
      6     SELECT 1945, 100 FROM dual union all
      7     SELECT 1921, 101 FROM dual)
      8  SELECT TO_DATE(yr||day_no, 'yyyyddd') dt FROM t;
    DT
    22-JUL-2009
    20-JUL-2006
    09-APR-1999
    01-JAN-2000
    10-APR-1945
    11-APR-1921It is the way that format masks are applied that causes his. With your mask and numeric iinput, it is taking the first 3 digits as the day number, in your example 902, then the remainder of them as the year, in your example 9. Obviously, the number of days in a year is never more than 366.
    By reversing the mask, the first 4 digits are taken as the year, and the remainder are taken as the day number.
    John

  • Need a simple program equivalent to the PC paint

    I need a simple program that is equivalent to the Windows paint program thats free.

    Does Paintbrush do what you want?
    (30512)

  • Please help me with simple program

    Can someone please write a simple program for me that opens up a webpage in the center of the screen , with a set size, and then asks the user where they would like to click on the screen. Then once the person clicks it asks how many times they would like to click there, and then once they enter the # the program opens up the webpage (in the center at the same spot as before, with the same set size) and automatically clicks on the predesignated spot , and then closes all open internet windows, and keeps doing it for however many times the person chose. PLEASE HELP ME WITH THIS!!! If you could, please post the source code here. Thank you so much to whoever helps me!!!!!!!

    If it's not to learn, then what is the purpose of
    this project?well, if it's not HW and its not for learning java, then why the hell would anyone like to have a program that may open a webpage and then repeatedly click on predefined place...
    let me see...
    now if he had asked for program that fakes IP as well, then i would suggest that he tryes to generate unique clicks, but now... i'm not sure... maybe just voting in some polls or smthing... though, i would not create a program that clicks on the link or form element, but rather just reload url with given parameters for N times...

  • How to Run a simple program using JMS Queue.!!

    Hi All,
    I am trying to run simple program on JMS Queue.
    Using SOA Suite 10.1.3.2
    I created a connection factory and queue using EM.
    Connection Factory => Domain : Queue JNDI Location : jms/sidConnectionFactory
    Queue Name : SidQueue JNDI Location : jms/SidQueue
    Tried running a simple java class to send the messages to queue.[Pls find the file attached].
    Getting this error
    javax.naming.NamingException: META-INF/application-client.xml not found (see J2EE spec, application-client chapter for requirements and format of the file)
    at oracle.j2ee.naming.ApplicationClientInitialContextFactory.getRequiredClasspathResource(ApplicationClientInitialContextFactory.java:239)
    at oracle.j2ee.naming.ApplicationClientInitialContextFactory.getArchive(ApplicationClientInitialContextFactory.java:161)
    at oracle.j2ee.naming.ApplicationClientInitialContextFactory.getInitialContext(ApplicationClientInitialContextFactory.java:111)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
    Can some one tell me how i need to create this file and where to place this[i.e is this need to be placed in  my project or some directory structure of <SOA-HOME>
    Thx,
    Siddhardha.
    Code:
    package demo;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.Properties;
    import javax.jms.*;
    import javax.naming.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class JMSQueue {
        public static void main(String args[])
    QueueConnection queueConnection;
    QueueSession queueSession;
    //private MessageProducer producer;
    QueueSender queueSender;
    try {          
    String message = "Test";
    String connectionFactoryName = "jms/sidConnectionFactory";
    String destinationName = "jms/SidQueue";
    /*Do i need to use this .......
    * If so where is the error in below statements...
    * Properties env = new Properties( );
    // ... specify the JNDI properties specific to the vendor
    env.put(Context.SECURITY_PRINCIPAL, "admin");
    env.put(Context.SECURITY_CREDENTIALS, "welcome");
    env.put(Context.INITIAL_CONTEXT_FACTORY,
    "com.evermind.server.ApplicationClientInitialContextFactory");
    env.put(Context.PROVIDER_URL,
    "ormi://localhost:23791");
    Context ctx = new InitialContext();
    // Get the connection factory.
    QueueConnectionFactory cf = (QueueConnectionFactory)ctx.lookup(connectionFactoryName);
    // Get the destination.
    Queue destination = (Queue) ctx.lookup(destinationName);
    // Use the connection factory to create a connection.
    queueConnection = cf.createQueueConnection();
    // Start the connection.
    queueConnection.start();
    // Use the connection to create a session.
    queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
    // Use the session and destination to create a message producer and a message consumer.
    //producer = queueSession.createProducer(destination);
    queueSender = queueSession.createSender(destination);
    TextMessage msg = queueSession.createTextMessage(message);
    queueSender.send(msg);
    queueSession.close();
    queueConnection.close();
    catch (Exception ex) {
    ex.printStackTrace();
    * Attached following libraries to the Project
    * jms.jar
    * optic.jar
    * oc4jclient.jar
    */

    Hi,
    You need to change the INITIAL_CONTEXT_FACTORY to com.evermind.server.RMIInitialContextFactory.
    Regards,
    Sandeep

  • Even a simple program is not working ?

    Hi there,
    I typed a simple program to display the customer details. The program goes like this :
    import java.lang.*;
    public class Customer
         String custname;
         String custID;
    public Customer()
         custname = "Bob";
         custID = "S20010";
    public void displaydetails()
         System.out.println("Customer name is " + custname);
         System.out.println("Customer ID is " + custID);
    public static void main(String a[])
         Customer cust = new Customer();
         cust.displaydetails();
    The compilation went right. But, when I executed the program the following error message is displayed :
    c:\>java Customer.java
    Exception in thread "main" java.lang.NoClassDefFoundError: Customer/java.
    Please help !!

    Don't cross-post.
    http://forum.java.sun.com/thread.jspa?threadID=576890&messageID=2891064#2891064

  • Need help with a simple program (should be simple anyway)

    I'm (starting to begin) writing a nice simple program that should be easy however I'm stuck on how to make the "New" button in the file menu clear all the fields. Any help? I'll attach the code below.
    ====================================================
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Message extends JFrame implements ActionListener {
         public void actionPerformed(ActionEvent evt) {
         text1.setText(" ");
         text2.setText("RE: ");
         text3.setText(" ");
         public Message() {
         super("Write a Message - by Kieran Hannigan");
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         setSize(370,270);
         FlowLayout flo = new FlowLayout(FlowLayout.RIGHT);
         setLayout(flo);
         //Make the bar
         JMenuBar bar = new JMenuBar();
         //Make "File" on Menu
         JMenu File = new JMenu("File");
         JMenuItem f1 = new JMenuItem("New");f1.addActionListener(this);
         JMenuItem f2 = new JMenuItem("Open");
         JMenuItem f3 = new JMenuItem("Save");
         JMenuItem f4 = new JMenuItem("Save As");
         JMenuItem f5 = new JMenuItem("Exit");
         File.add(f1);
         File.add(f2);
         File.add(f3);
         File.add(f4);
         File.add(f5);
         bar.add(File);
         //Make "Edit" on menu
         JMenu Edit = new JMenu("Edit");
         JMenuItem e1 = new JMenuItem("Cut");
         JMenuItem e2 = new JMenuItem("Paste");
         JMenuItem e3 = new JMenuItem("Copy");
         JMenuItem e4 = new JMenuItem("Repeat");
         JMenuItem e5 = new JMenuItem("Undo");
         Edit.add(e5);
         Edit.add(e4);
         Edit.add(e1);
         Edit.add(e3);
         Edit.add(e2);
         bar.add(Edit);
         //Make "View" on menu
         JMenu View = new JMenu("View");
         JMenuItem v1 = new JMenuItem("Bold");
         JMenuItem v2 = new JMenuItem("Italic");
         JMenuItem v3 = new JMenuItem("Normal");
         JMenuItem v4 = new JMenuItem("Bold-Italic");
         View.add(v1);
         View.add(v2);
         View.add(v3);
         View.addSeparator();
         View.add(v4);
         bar.add(View);
         //Make "Help" on menu
         JMenu Help = new JMenu("Help");
         JMenuItem h1 = new JMenuItem("Help Online");
         JMenuItem h2 = new JMenuItem("E-mail Programmer");
         Help.add(h1);
         Help.add(h2);
         bar.add(Help);
         setJMenuBar(bar);
         //Make Contents of window.
         //Make "Subject" text field
         JPanel row2 = new JPanel();
         JLabel sublabel = new JLabel("Subject:");
         row2.add(sublabel);
         JTextField text2 = new JTextField("RE:",24);
         row2.add(text2);
         //Make "To" text field
         JPanel row1 = new JPanel();
         JLabel tolabel = new JLabel("To:");
         row1.add(tolabel);
         JTextField text1 = new JTextField(24);
         row1.add(text1);
         //Make "Message" text area
         JPanel row3 = new JPanel();
         JLabel Meslabel = new JLabel("Message:");
         row3.add(Meslabel);
         JTextArea text3 = new JTextArea(6,22);
         messagearea.setLineWrap(true);
         messagearea.setWrapStyleWord(true);
         JScrollPane scroll = new JScrollPane(text3,
                                  JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                                  JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
         //SpaceLine
         JPanel spaceline = new JPanel();
         JLabel spacer = new JLabel(" ");
         spaceline.add(spacer);
         row3.add(scroll);
         add(row1);
         add(row2);
         add(spaceline);
         add(spaceline);
         add(row3);
         setVisible(true);
         public static void main(String[] arguments) {
         Message Message = new Message();
    }

    persiandude wrote:
    Topic: Need help with if, else, and which statements and loops.
    How would I display 60 < temp. <= 85 in java
    System.out.println("60 < temp. <= 85 in java");
    another question is how do I ask a question like want to try again (y/n) after a output and asking that everytime I type in yes after a output and terminate when saying No.Sun's [basic Java tutorial|http://java.sun.com/docs/books/tutorial/]
    Sun's [New To Java Center|http://java.sun.com/learning/new2java/index.html].Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
    [http://javaalmanac.com|http://javaalmanac.com]. A couple dozen code examples that supplement [The Java Developers Almanac|http://www.amazon.com/exec/obidos/tg/detail/-/0201752808?v=glance].
    jGuru. A general Java resource site. Includes FAQs, forums, courses, more.
    JavaRanch. To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
    Bruce Eckel's [Thinking in Java|http://mindview.net/Books/DownloadSites] (Available online.)
    Joshua Bloch's [Effective Java|http://www.amazon.com/Effective-Java-2nd-Joshua-Bloch/dp/0321356683/ref=pd_bbs_1?ie=UTF8&s=books&qid=1214349768&sr=8-1]
    Bert Bates and Kathy Sierra's [Head First Java|http://www.amazon.com/exec/obidos/tg/detail/-/0596004656?v=glance].
    James Gosling's [The Java Programming Language|http://www.bookpool.com/sm/0321349806].

Maybe you are looking for

  • How do I save a snapshot from a video in iphoto

    when taking pics with my digital camera I inadvertently recorded a short video. I'd like to cut out a picture from that, I've isolated the frame, but don't see how to make it into a snapshot that I could then edit and use as a picture. Any ideas? Tha

  • Clicking problem on popup menus

    When I am on the Amazon.com home page and I click on a sidebar menu a cascading popup menu appears. When I click on one of the popup menu items, the click registers on the graphic behind the menu, which takes me to the page related to the background

  • Error when accessing MIME-Content of emails through EWS

    Hello, i've a problem downloading the mime-content of some emails using exchange web services. Here is the code i'm using:             exService = new ExchangeService();             exService.Credentials = new NetworkCredential("user", "password", "d

  • Trying to configure an Async port on a 1760

    is there a difference in the way async ports are configured between 1800 and 1700 RTRs? i have 3 remote 1800 RTRs that have a dialup backup link via a modem connected to the AUX port. they work great. so now i'm tasked with doing the same with a 1760

  • Need Detailed description of the differences between Adobe Flash Player Plugin and Shockwave Flash

    For many years now I have been in a quandry over Adobe Flash (plugin) and Shockwave flash. The quandry is also somewhat exacerbated by the variety of subsetted versions supplied for each. You know, it is sorta like the name and namespace dilemna prov