Help creating struct in c for jni

Hi. I want to create a c-struct whose values are assigned by getting fields from java using jni.
For example,
in java: I have some variables, such as:
string a;
byte[] b;
someClass s; // this is another class who has its own variables
Now, I am able to get the values for each variable; however, I want to return those values to my functions so I can manipulate them. So, I need to create a c-struct for those vars. I can create a struct that will have a variable for string a as char *s.  Though, I am not sure how to assign or use byte in c so I can assign the value for byte array.  Finally, I wonder how you can include another class's variables in c-struct ( i.e., someClass s)
Please help on this issue. Thanks in advance.

Never mind....

Similar Messages

  • Digital Publishing Suite Help | Creating custom viewer apps for the iPad and iPhone

    This question was posted in response to the following article: http://helpx.adobe.com/digital-publishing-suite/help/create-custom-viewer-app-ipad.html

    The Approval Status section is no longer in DPS App Builder, but this reference wasn't removed. You can submit your app to the gallery using this form:
    https://adobeformscentral.com/?f=ozjJFvlBionBofBtd-wjbQ#

  • Creating a shared library for JNI in windows

    I went through the JNi tutorial online and it worked just fine on a Linux computer. Now I'm trying to make do the same tutorial on windows. When I get to the step 4. Create a Shared Library, I'm stuck. I don't know how to create this shared library on windows. It gives an example using Visual C++ but I don't have that. Any tips or advice out there what I should do? Any help would be greatly appreciated.

    //mac.java
    class mac
        public native void getMac();
        private native String getLine(String prompt);
        static {
         System.loadLibrary("myMac");//This is myMac.DLL
         /*if generated by borland
         System.loadLibrary("mymac");//This is mymac.dll
         public static void main(String[] args)
        mac mc=new mac();
        String input = mc.getLine("Enter Some Thing ");
        System.out.println("You Entered " + input);
        System.out.println(mc.getMac());
    prompt> javac mac.java
    prompt> javah -jni mac
    Borland compiler
    /*mymac.c*/
    #include <jni.h>
    #include "mac.h"
    #include <stdio.h>
    JNIEXPORT void JNICALL
    Java_mac_getMac(JNIEnv *env, jobject obj)
        printf("I am in  getmac dir in mymac.dll (Borland) \n");
        return;
    JNIEXPORT jstring JNICALL
    Java_mac_getLine(JNIEnv *env, jobject obj, jstring enter)
        char buf[128];
        const char *str = (*env)->GetStringUTFChars(env, enter, 0);
        printf("%s", str);
        (*env)->ReleaseStringUTFChars(env, enter, str);
        scanf("%s", buf);
        return (*env)->NewStringUTF(env, buf);
    To generate DLL
    create bcc32.cfg file in %BORLAND_INSTALL%/BCC5/bin Folder
    In the bcc32.cfg file add following code
    -I"%BORLAND_INSTALL%\BCC55\include;%JAVA_HOME%\include;%JAVA_HOME%\include\win32"
    -L"%BORLAND_INSTALL%\BCC55\lib;%BORLAND_INSTALL%\BCC55\Lib\PSDK;"
    i.e the path for borland compiler and java.
    now goto prompt and say
    prompt>bcc32 -tWM -tWD mymac.c
    This will create mymac.lib File
    Now say
    prompt>implib -c mymac.lib mymac.dll
    That's it!!
    there you are with dll
    Now you can run the mac.class file by using java
    VC++
    Click File->New->Win32Dynamic-Link Library
    Give name and Select
    A simple DLL project
    You will have
    myMac.CPP file
    // myMac.cpp : Defines the entry point for the DLL application.
    #include "stdafx.h"
    #include "mac.h"
    #include "jni.h" //can copy or give full path
    #include <math.h>
    BOOL APIENTRY DllMain( HANDLE hModule,
                           DWORD  ul_reason_for_call,
                           LPVOID lpReserved
        return TRUE;
    JNIEXPORT void JNICALL
    Java_mac_getMac(JNIEnv *env, jobject obj)
        printf("You are in getMac (VC++) DLL\n");
    JNIEXPORT jstring JNICALL
    Java_mac_getLine(JNIEnv *env, jobject obj, jstring enter)
        char buf[128];
        const char *str = env->GetStringUTFChars(enter, 0);
        printf("\n%s", str);
        env->ReleaseStringUTFChars(enter, str);
        scanf("%s", buf);
        return env->NewStringUTF(buf);
    Hope this is useful
    regards
    kanad Deshpande

  • Help creating a boot disk for ailing powerbook (and journalist!)

    Hello, I'm a journalist with a desperate need to recover my Mac.
    My Powerbook G4 (operating 10.4.8 I believe) was working fine until I did the latest suggested Mac software upgrade of Safari. Immediately Safari stopped responding hanging up or quitting. So I tried the next recommended update, thinking perhaps the two went together: Security 2008-009 I believe. It required a restart, which I did. (Note: I didn't do the recommended Java or Quicktime update at the same time because I'm currently working in Sierra Leone with terribly slow internet and figured I'd get to it later).
    Now, however, the computer won't boot up. I hear the tone, I get the gray screen with the apple, I get the blue screen, I get the opening OS X screen and the blue progress bar, which then quits early on. Then I get a blue screen of alternating hues, which continues infinitely.
    I tried all the Apple and web-suggested fixes. I cannot enter safe mode and can only perform functions with the single user mode. I've tried fsck and it said my HD is fine. The problem, I suspect, would be easy enough to fix if I could just reinstall OS X with my CD. However I am currently 7000 miles from home and CD, and in desperate need of my laptop in order to continue my volunteer work.
    I do have access to a friend's MacBook Pro 10.4.9 and the internet. I have downloaded Carbon Copy Cloner... however I don't know which files I need to copy in order to create a boot disk. Nor do I know how to create a boot disk to actually put into my computer. I have also been scared by the CCC literature that says I need to erase the target volume... which in this case is my external hard drive containing all of our video footage from the last 8 months!
    I use my computer every day, however I am a newbie at using things like Terminal and higher order functions that these occasions seem to require. CCC's Help manual, for me, might as well have been written in hieroglyphs (which, come to think of it, would have been easier as I seem to understand pictures well enough).
    I would be eternally grateful for any simple or step-by-step advice which might help me get back to work. I'm training African journalists, and without my computer to edit, we cannot do a thing!
    Thanks,
    Kim

    Here's some trouble shooting methods that I've copied from Apple KB articles:
    Resetting PRAM and NVRAM
    Shut down the computer.
    Locate the following keys on the keyboard: Command, Option, P, and R. You will need to hold these keys down simultaneously.
    Turn on the computer.
    Press and hold the Command-Option-P-R keys. You must press this key combination before the gray screen appears.
    Hold the keys down until the computer restarts and you hear the startup sound for the second time. Release the keys.
    If zapping the PRAM doesn't work, try resetting the PMU.
    Warning: Resetting the power manager also resets date and time settings. Performing a PMU reset returns the iBook and PowerBook hardware, including NVRAM, to default settings and forces the computer to shut down.
    PowerBook G4 (DVI) and PowerBook G4 (1 GHz/867 MHz)
    If the computer is on, turn it off.
    Disengage the two keyboard latches located between the Esc and F1 keys, and the F11 and
    F12 keys. (You may also need to disengage the keyboard locking screw located between the
    F5 and F6 keys.)
    Lift the keyboard. To ensure no harmful static electricity is transferred to the computer,
    properly ground yourself before performing this procedure.
    Press and release the reset button located on the upper right side of the logic board near the power button, shown here. Wait 5 seconds.
    Press the power button to restart the computer.
    PowerBook G4 and PowerBook G4 (Gigabit Ethernet)
    If the computer is on, turn it off.
    Press and release the reset button located on the rear panel of the computer between the
    external video and modem ports. Wait 5 seconds.
    Press the Power button to restart the computer.
    HTH!

  • Help creating an animated gif for a navbar!!

    Hey guys, I am very new to fireworks and dreamweave and am having a problem that is making my head spin! I have to create a simple animated .gif for a navigation bar (which will be made in dreamweaver). The navigation bar should function similar to this: http://www.eden.rutgers.edu/~baronson/ITI320/Exercise2/functionality.html. Essentially, all that is happening is I create this animated image and in dreamweaver, when I create the AP NavBar, I set the mouseover to that image. My problem is that in comparison to this website's mouseover image  ( http://www.eden.rutgers.edu/~baronson/ITI320/Exercise2/images/navi/audience_OVER.gif ) my animated gif has multiple layers and states, where as his only has one layer. I can't seem to figure out how to include both the text, and the gif image, and incorporate them under the same layer.
    A follow up question after having found how to incorporate both into the same state, would I have to lasso out each piece of my animated gif for the individual state I want to have it applied to?
    Any help/pointer to where the information can be found would be greatly appreciated. I've read through the manuals and watched many of Babbage's videos but haven't been able to figure this out. Thanks!

    Your gif doesn't need to have multiple layers, but it does need to have multiple states. To save yourself a lot of confusion, create the animated gifs first, and then export them. Create your navbar in the usual way, with simple rolloveres or swap images. Export the navbar.Rename the animated gifs with the names of the over state of the navbar images, and then delete (or mone to another folder) the over state images of the navbar. Move the renamed gif animations into the image folder of the navbar. Preview in browser. The animated gifs should have replaced the original over state of the buttons.

  • Help creating custom XMP file for Photoshop CS5

    I was wondering if there is anyone out there that would be willing to help me create a custom XMP file for Photoshop CS5. What I need is very simple, I really just don't know how to go about creating it myself.
    Feel free to email me at [email protected]

    Hi Robert,
    please have a look at the "Generic Panel" example of the File Info SDK.
    Using that you only need to create a simple XML-file to create a simple custom panel.
    -- Stefan Makswit

  • Help creating a site-map for my iweb website

    Hello,
    I was able to list my site with google, no problem. However, following the instructions below to verify didn't work. #1- text edit has no choice for a simple text file. #2 - my mac will not allow me to save any kind of file except html file ending with html. #3 - I've tried using word and no matter what kind of save I attempt to save the google file name, I keep getting the same message, which is -> Verification status: NOT VERIFIED
    We've detected that your 404 (file not found) error page returns a status of 200 (Success) in the header.
    And the site map thing is simply over my head. Any help would be greatly appreciated. thanks ---- Roy
    Here's what I want you to do... your going to register with Google, submit your site for verification, and then make and submit a sitemap for your site. Okay? Here goes...
    Go to this page and login or register for a Google account... http://www.google.com/webmasters/
    This opens up a lot of tools to see how your site is doing. I have already confirmed that Google has none of your pages in its index using the Site Status Wizard.
    Once registered, click on "Webmaster Tools" and then enter your iWeb URL under "Add Site". I want you to type in your iWeb URL like this: http://web.mac.com/jlutz/iWeb/
    Click OK. Congratulations, your site is registered with Google. Now onto verifying that it is your site...
    Click on "Verify" next to your registered URL. You'll be presented with a choice of verification methods. Choose "Upload an HTML file". Google will give you the filename to use, like "googlef429021c837438ca.html" All you have to do is to create a blank file with TextEdit. Save it to your desktop as a plain text file. Then rename it with the filename that Google gave you (yes you want to use the .html extension in case you are asked). Then just copy this file to your iDisk/Web/Sites/iWeb/ folder. That's it.
    Click Verify...you should get verified immediately. Congratulations.

    simon4423,
    Here are some other sites you might find helpful (for free):
    http://www.varkgirl.com/Varkgirl/Google%20and%20iWeb.html
    http://karreth.com/mac/index.php/become-no1-on-google-with-iweb/
    The error you are seeing (We've detected that your 404 (file not found) error page returns a status of 200 (Success) in the header.) is something I have noticed on and off with my .Mac sites lately too. It used to work fine, but now sometimes .Mac verifies, sometimes it doesn't. Try both verification methods and see if one works over the other. If you are still having trouble, I know Max (
    http://karreth.com) is really good at this stuff so you might try emailing him about it.
    Varkgirl

  • Help creating .dll with c using JNI

    Hi. I have created a JNI application that uses C to call Java. Now, I am trying to create the .dll for windows. I am using VS C++ compiler. My program compiles; however, it doesn't seem to start the JVM. I am not sure how to pass the arguments in VS C++ while builiding and running. Please let me know. Thanks.

    Hey,
    Thanks. I apologize for not being clear. I have created the dll file and an application that links to that dll and executes the code. It creates the .exe file and when I execute it, it goes through the sample() function that just prints "Hello", and then it goes through the startJVM() function where the JVM is intended to start; however, the status of JVM is returning -1. It's not able to start JVM. I have included the path for the jvm.dll and jvm.lib. But, still won't work. Please reply with suggestions/comments. Thanks again.

  • Help creating an external array for a scoreboard

    I'm trying to create an array in an external file that will recieve and arrange scores sent from Quiz.fla upon clicking the submit score button.  I also want another fla file to be able to reference this external array and pull the top 15 scores from it, and then display those scores on a scrolling banner.  I want the banner to be able to update dynamically (I assume reloading the banner fla each time it reaches the end of its cycle, having the first frame load the external array on an onClipEvent action would accomplish this), that way it will update while remaining open.  The main reason I need two separate files for the quiz and the score banner is they will be displayed on two different monitors.  What would be the most efficient way of accomplishing this?  I know a little about actionscript but I don't have much experience with calling data and functions from external fla or as files (the array and the function designating how the data will be arranged within said array are going to be in a separate .as file).
    I'm currently working in AS2, since I've had almost no experience with AS3.

    So if I wanted to avoid using a server, I'd basically have to set up the
    array storing the high scores in an external .as or .swf file which would
    then be called into the quiz game to store the scores, and then called by
    the banner each time it hits frame 1 to refresh the numbers?  But then that
    would run into the problem of a shared object being used by two different
    clients I guess?  Servers setup and accessing confuses the hell out of me
    right now, so I'm trying not to make things to hellish for myself...
    Would there be a way to create 2 external database files within the folder
    holding the .swf files to somehow get around the issue of one sharedobject
    being accessed by two clients?

  • Need help creating a bootable dvd for solaris 9 using windows

    Ok, I am using windows XP, I have 2 hard drives in my computer and want to load Solaris 9 on my other hard drive. I have downloaded the ziped ISO files from sun.com, I have extracted them (sol-9-u8-ga-x86-dvd-iso-a, sol-9-u8-ga-x86-dvd-iso-b, sol-9-u8-ga-x86-dvd-iso-c, sol-9-u8-ga-x86-dvd-iso-d, and sol-9-u8-ga-x86-dvd-iso-e) Now what? I burned them to a DVD but its not booting to them (I have checked my boot sequence) I figured I would have to make a bootable DVD but I don't know how. All the instructions I am finding are for doing it in Solaris 9. Can someone please give me instructions on what I need to do now that I have downloaded the files or point me to a site that already has the instructions? Also I have Nero 7 Essentials as my DVD burning software.
    Thanks

    Copy all unzipped pieces into one directory (sol-9-u8-ga-x86-dvd-iso-a, sol-9-u8-ga-x86-dvd-iso-b etc... all 5 pieces)
    take command prompt and goto that directory and run the below command
    copy /b sol-9-u8-ga-x86-dvd-iso-a + sol-9-u8-ga-x86-dvd-iso-b + sol-9-u8-ga-x86-dvd-iso-c + sol-9-u8-ga-x86-dvd-iso-d + sol-9-u8-ga-x86-dvd-iso-e sol-9-u8-ga-x86-dvd-iso.iso
    It will create sol-9-u8-ga-x86-dvd-iso.iso file.
    Using any DVD Burner software (e.g. Nero 7 or later), Burn the newly ceated image ( sol-9-u8-ga-x86-dvd-iso.iso) do "Burn Image" (NOT a DATA DVD/CD)
    Regards,
    Prvn

  • Help create systemd .service file for Teeworlds server

    Hi there.
    I maintain one package the provide server for the game Teeworlds (teeworlds-zcatch in AUR). I'd like to have a ".service" file to be able to run the server in background, maybe even in startup, and saving the log (it send some stuff to stdout that could be nice to keep). However I don't know how to make a ".service" script. Could somene create a script or point me out to informations about it?
    Thanks in advance

    Hi.
    https://bbs.archlinux.org/viewtopic.php … 9#p1363959
    There I explain a little a .service that I'm using. Maybe it be useful.
    And in this wikipage there are several examples
    https://wiki.archlinux.org/index.php/Systemd/Services

  • Need help creating a folder action for creating folders based on filenames.

    I want to create a folder action that will monitor a folder and every time a file is added to the folder it will create a directory using the filename (minus the extension) and move the file the that directory

    on run {input, parameters} -- create folders from file names and move
      set output to {} -- this will be a list of the moved files
      repeat with anItem in the input -- step through each item in the input
        set {theContainer, theName, theExtension} to (getTheNames from anItem)
        try
          set destination to (makeNewFolder for theName at theContainer)
          tell application "Finder"
            move anItem to destination
            set the end of the output to the result as alias -- success
          end tell
        on error errorMessage -- duplicate name, permissions, etc
          log errorMessage
          # handle errors if desired - just skip for now
        end try
      end repeat
      return the output -- pass on the results to following actions
    end run
    to getTheNames from someItem -- get a container, name, and extension from a file item
      tell application "System Events" to tell disk item (someItem as text)
        set theContainer to the path of the container
        set {theName, theExtension} to {name, name extension}
      end tell
      if theExtension is not "" then
        set theName to text 1 thru -((count theExtension) + 2) of theName -- just the name part
        set theExtension to "." & theExtension
      end if
      return {theContainer, theName, theExtension}
    end getTheNames
    to makeNewFolder for theChild at theParent -- make a new child folder at the parent location if it doesn't already exist
      set theParent to theParent as text
      if theParent begins with "/" then set theParent to theParent as POSIX file as text
      try
        return (theParent & theChild) as alias
      on error errorMessage -- no folder
        log errorMessage
        tell application "Finder" to make new folder at theParent with properties {name:theChild}
        return the result as alias
      end try
    end makeNewFolder
    This script almost does what I need except for the fact that it screws up on files with periods in them
    for example
    1.2.3.4.txt
    will create the directorys 1, 2, 3, and 4 instead of 1.2.3.4

  • JFreeChart Help:  Creating a Gradient Background for a CategoryPlot

    I need a Gradient Background for my CategoryPlot Object and am having problems figuring out the best approach.
    Does anyone have any suggestions on the best way to approach this problem?
    Any help would be appreciated.

            BarRenderer barrenderer = (BarRenderer)categoryplot.getRenderer();
            barrenderer.setDrawBarOutline(false);
            GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64));
            GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0));
            barrenderer.setSeriesPaint(0, gradientpaint);
            barrenderer.setSeriesPaint(1, gradientpaint1);

  • Help creating a netboot image for Panther in SIU

    Hi!
    I have an old iBook G3 that has a broken CDROM drive.
    I want to install Panther on it, so I'm thinking to netboot it from my SNow Leopard server.
    I tried creating a netboot image from the original Panther CD, using the System Image Utility in SL but it seems I can only create images of Snow Leopard.
    This limitation seems strange.
    Is there a way to create a netboot image from my Panther CD and use it to beet my ibook ?
    Any information online on how to achieve this?
    Thanks
    Mike

    Thanks Antonio !
    That's a really good answer.
    I just need to add some more info:
    I downloaded the Server Admin tools from the link you gave me but it would not install on 10.6.1 Server nor on 10.5 client.
    I get the error:
    "You cannot install Server Admin Tools on this volume. You are not allowed to install the software on this disk for an unknown reason."
    Thus I extracted manually the System Image Utility from Installers/Packages/ServerAdminTools.pkg/Contents/Archive.pax.gz
    The application runs fine on Leopard client and SL server.
    I just need to figure out now how to boot my iBook.

  • Need to create a driver class for a program i have made...

    hey guys im new to these forums and someone told me that i could get help on here if i get in a bind...my problem is that i need help creating a driver class for a program that i have created and i dont know what to do. i need to know how to do this is because my professor told us after i was 2/3 done my project that we need at least 2 class files for our project, so i need at least 2 class files for it to run... my program is as follows:
    p.s might be kinda messy, might need to put it into a text editor
    Cipher.java
    This program encodes and decodes text strings using a cipher that
    can be specified by the user.
    import java.io.*;
    public class Cipher
    public static void printID()
    // output program ID
    System.out.println ("*********************");
    System.out.println ("* Cipher *");
    System.out.println ("* *");
    System.out.println ("* *");
    System.out.println ("* *");
    System.out.println ("* CS 181-03 *");
    System.out.println ("*********************");
    public static void printMenu()
    // output menu
    System.out.println("\n\n****************************" +
    "\n* 1. Set cipher code. *" +
    "\n* 2. Encode text. *" +
    "\n* 3. Decode coded text. *" +
    "\n* 4. Exit the program *" +
    "\n****************************");
    public static String getText(BufferedReader input, String prompt)
    throws IOException
    // prompt the user and get their response
    System.out.print(prompt);
    return input.readLine();
    public static int getInteger(BufferedReader input, String prompt)
    throws IOException
    // prompt and get response from user
    String text = getText(input, prompt);
    // convert it to an integer
    return (new Integer(text).intValue());
    public static String encode(String original, int offset)
    // declare constants
    final int ALPHABET_SIZE = 26; // used to wrap around A-Z
    String encoded = ""; // base for string to return
    char letter; // letter being processed
    // convert message to upper case
    original = original.toUpperCase();
    // process each character of the message
    for (int index = 0; index < original.length(); index++)
    // get the letter and determine whether or not to
    // add the cipher value
    letter = original.charAt(index);
    if (letter >='A' && letter <= 'Z')
    // is A-Z, so add offset
    // determine whether result will be out of A-Z range
    if ((letter + offset) > 'Z') // need to wrap around to 'A'
    letter = (char)(letter - ALPHABET_SIZE + offset);
    else
    if ((letter + offset) < 'A') // need to wrap around to 'Z'
    letter = (char)(letter + ALPHABET_SIZE + offset);
    else
    letter = (char) (letter + offset);
    // build encoded message string
    encoded = encoded + letter;
    return encoded;
    public static String decode(String original, int offset)
    // declare constants
    final int ALPHABET_SIZE = 26; // used to wrap around A-Z
    String decoded = ""; // base for string to return
    char letter; // letter being processed
    // make original message upper case
    original = original.toUpperCase();
    // process each letter of message
    for (int index = 0; index < original.length(); index++)
    // get letter and determine whether to subtract cipher value
    letter = original.charAt(index);
    if (letter >= 'A' && letter <= 'Z')
    // is A-Z, so subtract cipher value
    // determine whether result will be out of A-Z range
    if ((letter - offset) < 'A') // wrap around to 'Z'
    letter = (char)(letter + ALPHABET_SIZE - offset);
    else
    if ((letter - offset) > 'Z') // wrap around to 'A'
    letter = (char)(letter - ALPHABET_SIZE - offset);
    else
    letter = (char) (letter - offset);
    // build decoded message
    decoded = decoded + letter;
    return decoded;
    // main controls flow throughout the program, presenting a
    // menu of options the user.
    public static void main (String[] args) throws IOException
    // declare constants
    final String PROMPT_CHOICE = "Enter your choice: ";
    final String PROMPT_VALID = "\nYou must enter a number between 1" +
    " and 4 to indicate your selection.\n";
    final String PROMPT_CIPHER = "\nEnter the offset value for a caesar " +
    "cipher: ";
    final String PROMPT_ENCODE = "\nEnter the text to encode: ";
    final String PROMPT_DECODE = "\nEnter the text to decode: ";
    final String SET_STR = "1"; // selection of 1 at main menu
    final String ENCODE_STR = "2"; // selection of 2 at main menu
    final String DECODE_STR = "3"; // selection of 3 at main menu
    final String EXIT_STR = "4"; // selection of 4 at main menu
    final int SET = 1; // menu choice 1
    final int ENCODE = 2; // menu choice 2
    final int DECODE =3; // menu choice 4
    final int EXIT = 4; // menu choice 3
    final int ALPHABET_SIZE = 26; // number of elements in alphabet
    // declare variables
    boolean finished = false; // whether or not to exit program
    String text; // input string read from keyboard
    int choice; // menu choice selected
    int offset = 0; // caesar cipher offset
    // declare and instantiate input objects
    InputStreamReader reader = new InputStreamReader(System.in);
    BufferedReader input = new BufferedReader(reader);
    // Display program identification
    printID();
    // until the user selects the exit option, display the menu
    // and respond to the choice
    do
    // Display menu of options
    printMenu();
    // Prompt user for an option and read input
    text = getText(input, PROMPT_CHOICE);
    // While selection is not valid, prompt for correct info
    while (!text.equals(SET_STR) && !text.equals(ENCODE_STR) &&
    !text.equals(EXIT_STR) && !text.equals(DECODE_STR))
    text = getText(input, PROMPT_VALID + PROMPT_CHOICE);
    // convert choice to an integer
    choice = new Integer(text).intValue();
    // respond to the choice selected
    switch(choice)
    case SET:
         // get the cipher value from the user and constrain to
    // -25..0..25
    offset = getInteger(input, PROMPT_CIPHER);
    offset %= ALPHABET_SIZE;
    break;
    case ENCODE:
    // get message to encode from user, and encode it using
    // the current cipher value
    text = getText(input, PROMPT_ENCODE);
    text = encode(text, offset);
    System.out.println("Encoded text is: " + text);
    break;
    case DECODE:
    // get message to decode from user, and decode it using
    // the current cipher value
    text = getText(input, PROMPT_DECODE);
    text = decode(text, offset);
    System.out.println("Decoded text is: " + text);
    break;
    case EXIT:
    // set exit flag to true
    finished = true ;
    break;
    } // end of switch on choice
    } while (!finished); // end of outer do loop
    // Thank user
    System.out.println("Thank you for using Cipher for all your" +
    " code breaking and code making needs.");
    }

    My source in code format...sorry guys :)
       Cipher.java
       This program encodes and decodes text strings using a cipher that
       can be specified by the user.
    import java.io.*;
    public class Cipher
       public static void printID()
          // output program ID
          System.out.println ("*********************");
          System.out.println ("*       Cipher      *");
          System.out.println ("*                   *");
          System.out.println ("*                          *");
          System.out.println ("*                   *");
          System.out.println ("*     CS 181-03     *");
          System.out.println ("*********************");
       public static void printMenu()
          // output menu
          System.out.println("\n\n****************************" +
                               "\n*   1. Set cipher code.    *" +
                               "\n*   2. Encode text.        *" +
                               "\n*   3. Decode coded text.  *" +
                               "\n*   4. Exit the program    *" +
                               "\n****************************");
       public static String getText(BufferedReader input, String prompt)
                                           throws IOException
          // prompt the user and get their response
          System.out.print(prompt);
          return input.readLine();
       public static int getInteger(BufferedReader input, String prompt)
                                           throws IOException
          // prompt and get response from user
          String text = getText(input, prompt);
          // convert it to an integer
          return (new Integer(text).intValue());
       public static String encode(String original, int offset)
          // declare constants
          final int ALPHABET_SIZE = 26;  // used to wrap around A-Z
          String encoded = "";           // base for string to return
          char letter;                   // letter being processed
          // convert message to upper case
          original = original.toUpperCase();
          // process each character of the message
          for (int index = 0; index < original.length(); index++)
             // get the letter and determine whether or not to
             // add the cipher value
             letter = original.charAt(index);
             if (letter >='A' && letter <= 'Z')          
                // is A-Z, so add offset
                // determine whether result will be out of A-Z range
                if ((letter + offset) > 'Z') // need to wrap around to 'A'
                   letter = (char)(letter - ALPHABET_SIZE + offset);
                else
                   if ((letter + offset) < 'A') // need to wrap around to 'Z'
                      letter = (char)(letter + ALPHABET_SIZE + offset);
                   else
                      letter = (char) (letter + offset);
             // build encoded message string
             encoded = encoded + letter;
          return encoded;
       public static String decode(String original, int offset)
          // declare constants
          final int ALPHABET_SIZE = 26;  // used to wrap around A-Z
          String decoded = "";           // base for string to return
          char letter;                   // letter being processed
          // make original message upper case
          original = original.toUpperCase();
          // process each letter of message
          for (int index = 0; index < original.length(); index++)
             // get letter and determine whether to subtract cipher value
             letter = original.charAt(index);
             if (letter >= 'A' && letter <= 'Z')          
                // is A-Z, so subtract cipher value
                // determine whether result will be out of A-Z range
                if ((letter - offset) < 'A')  // wrap around to 'Z'
                   letter = (char)(letter + ALPHABET_SIZE - offset);
                else
                   if ((letter - offset) > 'Z') // wrap around to 'A'
                      letter = (char)(letter - ALPHABET_SIZE - offset);
                   else
                      letter = (char) (letter - offset);
             // build decoded message
             decoded = decoded + letter;
          return decoded;
       // main controls flow throughout the program, presenting a
       // menu of options the user.
       public static void main (String[] args) throws IOException
         // declare constants
          final String PROMPT_CHOICE = "Enter your choice:  ";
          final String PROMPT_VALID = "\nYou must enter a number between 1" +
                                      " and 4 to indicate your selection.\n";
          final String PROMPT_CIPHER = "\nEnter the offset value for a caesar " +
                                       "cipher: ";
          final String PROMPT_ENCODE = "\nEnter the text to encode: ";
          final String PROMPT_DECODE = "\nEnter the text to decode: ";
          final String SET_STR = "1";  // selection of 1 at main menu
          final String ENCODE_STR = "2"; // selection of 2 at main menu
          final String DECODE_STR = "3"; // selection of 3 at main menu
          final String EXIT_STR = "4";  // selection of 4 at main menu
          final int SET = 1;            // menu choice 1
          final int ENCODE = 2;         // menu choice 2
          final int DECODE =3;          // menu choice 4
          final int EXIT = 4;           // menu choice 3
          final int ALPHABET_SIZE = 26; // number of elements in alphabet
          // declare variables
          boolean finished = false; // whether or not to exit program
          String text;              // input string read from keyboard
          int choice;               // menu choice selected
          int offset = 0;           // caesar cipher offset
          // declare and instantiate input objects
          InputStreamReader reader = new InputStreamReader(System.in);
          BufferedReader input = new BufferedReader(reader);
          // Display program identification
          printID();
          // until the user selects the exit option, display the menu
          // and respond to the choice
          do
             // Display menu of options
             printMenu(); 
             // Prompt user for an option and read input
             text = getText(input, PROMPT_CHOICE);
             // While selection is not valid, prompt for correct info
             while (!text.equals(SET_STR) && !text.equals(ENCODE_STR) &&
                     !text.equals(EXIT_STR) && !text.equals(DECODE_STR))       
                text = getText(input, PROMPT_VALID + PROMPT_CHOICE);
             // convert choice to an integer
             choice = new Integer(text).intValue();
             // respond to the choice selected
             switch(choice)
                case SET:
                // get the cipher value from the user and constrain to
                   // -25..0..25
                   offset = getInteger(input, PROMPT_CIPHER);
                   offset %= ALPHABET_SIZE;
                   break;
                case ENCODE:
                   // get message to encode from user, and encode it using
                   // the current cipher value
                   text = getText(input, PROMPT_ENCODE);
                   text = encode(text, offset);
                   System.out.println("Encoded text is: " + text);
                   break;
                case DECODE:
                   // get message to decode from user, and decode it using
                   // the current cipher value
                   text = getText(input, PROMPT_DECODE);
                   text = decode(text, offset);
                   System.out.println("Decoded text is: " + text);
                   break;
                case EXIT:
                   // set exit flag to true
                   finished = true ;
                   break;
             } // end of switch on choice
          } while (!finished); // end of outer do loop
          // Thank user
          System.out.println("Thank you for using Cipher for all your" +
                             " code breaking and code making needs.");
    }

Maybe you are looking for

  • Assigning a value to a variable

    declare -- Local variables here v_temp1 number; v_temp2 number; v_temp3 number; v_final number; begin v_temp1 :=2; dbms_output.put_line('v_tmp1:'||v_temp1); dbms_output.put_line('v_tmp2:'||v_temp2); dbms_output.put_line('v_tmp3:'||v_temp3); --i shoul

  • Problem in converting the date format in Second's place

    I am developing an application using OAF in JDeveloper. I have to pass the current date from my page to a quary to filter the data. I used the following: String PresentDate=this.getOADBTransaction().getCurrentDBDate().toString(); However it is sendin

  • Price difference account settlement  process at period end

    Hi Is there any procedure to settle the price difffrence account (P&L Account)  at the month end/year end in FI.( for the material price difference araise on purchases, subcontracting  etc) How to settle, pls provide the steps? regards, maalik

  • Copying files into output directory automatically

    Hi I got two font files (e.g. a.ttf and b.ttf) which I want to be copied inside ViewController\classes automatically when I run the application. I copied them into ViewController\src but it didn't work. What should I do? Is there anything to be set?

  • Cross team resource allocation issue

    The group I am working with has 4 developers who work on 9 team projects in VSO. The teams working against these Team Project generally own more than one application and we are running into issues with resource allocations. Does anyone have any feedb