How to share an array among members of a package

I need to share the value of h among members of a package. The values for Byte h are generated by button events in the other program in the package [ sample below ]. That is transformed into ASCII code, h, which ideally should go through SerialWriter and out the serial port.
private void menuButtonActionPerformed(java.awt.event.ActionEvent evt) {                                          
        Charset asciiCharset = Charset.forName("US-ASCII");
     CharsetDecoder decoder = asciiCharset.newDecoder();
     byte h[] = {33, 48, 48, 66, 77, 69, 78, 85, 13}; //brings menu up
     ByteBuffer asciiBytes = ByteBuffer.wrap(h);
     CharBuffer hChars = null;
     try {
          hChars = decoder.decode(asciiBytes);
     } catch (CharacterCodingException e) {
          System.err.println("Error decoding");
          System.exit(-1);
          System.out.println(hChars);
    }                                          Predictably, when trying to run the main member of the package -- listed below -- h is not transferred, hence not instantiated, and I get a Null Pointer Exception. How can I transfer the value of h so that is seen by the "connect" method below? thanks
package desktopapplication1;
import org.jdesktop.application.Application;
import org.jdesktop.application.SingleFrameApplication;
import java.nio.*;
import java.nio.channels.*;
import java.nio.ByteBuffer.*;
import java.nio.charset.*;
import java.lang.String.*;
import java.io.*;
import java.util.*;
import gnu.io.*;
import java.nio.*;
import java.nio.channels.*;
import java.nio.ByteBuffer.*;
import java.nio.charset.*;
import gnu.io.CommPort;
import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
* The main class of the application.
public class DesktopApplication1 extends SingleFrameApplication {
        String defaultPort = "/dev/ttyS0";
     * At startup create and show the main frame of the application.
    @Override protected void startup() {
        show(new DesktopApplication1View(this));
     * This method is to initialize the specified window by injecting resources.
     * Windows shown in our application come fully initialized from the GUI
     * builder, so this additional configuration is not needed.
    @Override protected void configureWindow(java.awt.Window root) {
     * A convenient static getter for the application instance.
     * @return the instance of DesktopApplication1
    public static DesktopApplication1 getApplication() {
        return Application.getInstance(DesktopApplication1.class);
    public void connect ( String portName ) throws Exception {
     String defaultPort = "/dev/ttyS0";
        Byte h;
        CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName);
        if ( portIdentifier.isCurrentlyOwned() )
            System.out.println("Error: Port is currently in use");
        else
            CommPort commPort = portIdentifier.open(this.getClass().getName(),200);
            if ( commPort instanceof SerialPort )
                SerialPort serialPort = (SerialPort) commPort;
                serialPort.setSerialPortParams(4800,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
                InputStream in = serialPort.getInputStream();
                OutputStream out = serialPort.getOutputStream();
                (new Thread(new SerialReader(in))).start();
                (new Thread(new SerialWriter(out))).start();
          out.write(h);
          out.flush();
            else
                System.out.println("Error: Only serial ports are addressable by this application.");
     public static class SerialReader implements Runnable
        InputStream in;
        public SerialReader ( InputStream in )
            this.in = in;
        public void run ()
            byte[] buffer = new byte[1024];
            int len = -1;
            try
                while ( ( len = this.in.read(buffer)) > -1 )
                    System.out.print(new String(buffer,0,len));
            catch ( IOException e )
                e.printStackTrace();
    public static class SerialWriter implements Runnable {
        OutputStream out;
        SerialPort     serialPort;
        public SerialWriter ( OutputStream out )
            this.out = out;
        public void run ()
            try
                int c = 0;
                while ( ( c = System.in.read()) > -1 )
                    this.out.write(c);
            catch ( IOException e )
                e.printStackTrace();
         try {
                 Thread.sleep(2000);  // Be sure data is xferred before closing
              } catch (Exception e) {}
              serialPort.close();
              System.exit(1);
     * Main method launching the application.
    public static void main(String[] args) {
        launch(DesktopApplication1.class, args);
      try
            (new DesktopApplication1()).connect("/dev/ttyS0");
        catch ( Exception e )
            e.printStackTrace();
}

Make h global, and make an getH method in that class. And then make an instance of the class containing the getH() method, and call it from the connect() method.
private byte h[] = {33, 48, 48, 66, 77, 69, 78, 85, 13};
public byte[] getH() {
     return h;
private void menuButtonActionPerformed(java.awt.event.ActionEvent evt) {                                          
        Charset asciiCharset = Charset.forName("US-ASCII");
     CharsetDecoder decoder = asciiCharset.newDecoder();
      //brings menu up
     ByteBuffer asciiBytes = ByteBuffer.wrap(h);
     CharBuffer hChars = null;
     try {
          hChars = decoder.decode(asciiBytes);
     } catch (CharacterCodingException e) {
          System.err.println("Error decoding");
          System.exit(-1);
          System.out.println(hChars);
    }

Similar Messages

  • How to share audio with other members of a meeting?

    Hi,
    I want to share a video with my class but my student cannot hear the video since they only receive audio from my mic. I was wondering if there is a way I can share what I am hearing. If someone can provide me with instruction on how to do this I will highly appreciate it. I'm using adobe connect.
    Thank you,
    Jonathan R.

    Are you trying to share a video in the Share pod or via Screen sharing?
    Screen sharing only shares the image of your screen (or application), not the audio. Additionally most videos run at 24-30 FPS (frames per second), while screen sharing runs at 3-5 FPS. So a large amount of the visual information being displayed by your video is lost. If this is what you are doing, I'd recommend that you get an FLV or MP4 version of the video you are sharing and upload that directly to the Share pod. The playback will be sync'd among all attendees and the audio will come through their computer speakers.

  • How to share iPhoto library among users on same iMac without using an external drive?

    How can I share my iPhoto library with another user on the same iMac for use with iCloud. I do not want to use an external drive.
    Thanks

    For iPhoto 09 (version 8.0.2) and later:
    What you mean by 'share'.
    If you want the other user to be able to see the pics, but not add to, change or alter your library, then enable Sharing in your iPhoto (Preferences -> Sharing), leave iPhoto running and use Fast User Switching to open the other account. In that account, enable 'Look For Shared Libraries'. Your Library will appear in the other source pane.
    Any user can drag a pic from the Shared Library to their own in the iPhoto Window.
    Remember iPhoto must be running in both accounts for this to work.
    If you want the other user to have the same access to the library as you: to be able to add, edit, organise, keyword etc.
    Quit iPhoto in both accounts. Move the Library to the Users / Shared Folder
    (You can also use an external HD set to ignore permissions, a Disk Image or even partition your Hard Disk.)
    In each account in turn: Double click on the Library to open it. (You may be asked to repair the Library Permissions.) From that point on, this will be the default library location. Both accounts will have full access to the library, in fact, both accounts will 'own' it.
    However, there is a catch with this system and it is a significant one. iPhoto is not a multi-user app., it does not have the code to negotiate two users simultaneously writing to the database, and trying will cause db corruption. So only one user at a time, and back up, back up back up.

  • How to share an array?

    I want to share a list of visitors of chat room with SharedObject. I was going to put and array into shared object's field. Is it possible? And also I was realized that it is impossible to synchronize shared array correctly. If two visitors will add themselves to the list simultaneously, then one can be lost.
    Is it possible to synchronize access to shared object somehow or the only way is to write server side function to control the array?

    Hi,
    In the following document go through the section conflict resolution.
    http://help.adobe.com/en_US/FlashMediaServer/3.5_CS_ASD/WS5b3ccc516d4fbf351e63e3d11a070f7d df-7ec4.html
    I hope this will help you.

  • How to share a bookmarks among users on a network

    Hi,
    I posted this question to the MySQL forum and got no response, but it's kind of a UNIX-y type question, so maybe someone here can help.
    In a nutshell: I would like to share certain queries I that make and save in MySQL Query Browser so that other people in our company can run them. Normally, MySQL Query Browser savings queries in ~/Library/Application Support/MySQL/QueryBrowser/bookmarks.xml. If this file is not there, it creates it on startup.
    What I tried: I moved the real bookmarks.xml file to a network folder (to which everyone has read/write access). I made an alias of bookmarks.xml and put in where MySQL Query Browser expects it (~/Library/Application Support/MySQL/QueryBrowser/bookmarks.xml). But when I start QB, it overwrites the alias with a new blank bookmarks.xml. (I also tried doing this with a symlink, with the same results.)
    Anyone manage to do this? Is it even possible? Thanks.
    ...Rene

    Thanks.

  • How to Share web session among different OC4Js

    I am trying to do the following.
    I have two websites running on two different machines on two different OC4J instances. Now I want to login to be perform only on one website. If user is logged in to website A he shall be able to access site B without having to loggin once again. Is there anyway this could be done without having to use oracle OID since I'm only using OC4J stand alone. If user loggs off site A he should also be logged off site B.
    Any suggestions?

    The Oracle Java SSO mechanism in 10.1.3.1+ should allow you to do this. This is a "lightweight" SSO provider and does not require the use of OID.
    I'm pretty sure you can configure it to support SSO over different OC4J instances using the file based provider mechanism. As long as the same users/groups are populated in the file based user repository and JavaSSO is keyed the same across the different Oc4J instances I think it works.
    There's quite a few I thinks in there, so caveat emptor! But its simple enough to configure and uses only OC4J standalone, so its worth trying if you still don't have a solution.
    -steve-

  • HERE'S HOW TO SHARE iCAL w/ MULTIPLE USERS on 1 Mac

    Here's how to share iCal calendars among multiple users on a single Mac.
    What you need to do is to move the iCal folder to a shared folder that is accessible to all users and then replace the iCal folder in each user's library folder with a "symbolic link' to the shared iCal folder. The symbolic link looks like an "alias", but if you try this using "aliases" to the shared iCal folder it will not work (trust me). You can create symbolic links using the Terminal, but I have no idea how, and the idea of using the Terminal scares me. The easiest way that I know of to create a symbolic link is with a shareware application called Cocktail. It allows you to do a number of different things including System Maintenance, Network Optimization, etc. It took me a while to remember how to do this; I originally found the information in the Discussions when iCal was first released, but apparently none of those original postings are listed in the forums anymore.
    Here's how to do it (you must have Administrator privileges):
    First locate your iCal folder (your user name > Library > Application Support > iCal) and make a copy of it (Finder > File > Duplicate). Drag the copy to your Desktop until you're sure iCal is being shared between users.
    Next move the original iCal folder into a Shared folder in the Users folder (Hard Disk > Users > Shared > iCal). To make sure all users can access the information, select the Shared folder, choose File > Get Info, click the little Lock icon, then under "Ownership & Permissions -> Details" make sure that the "Owner" is "System", "Group" is "Wheel" and "Access" for Owner, Group and Others is "Read & Write". Do the same with the iCal folder within the Shared folder, but this time, under "Ownership & Permissions -> Details" make sure that the "Owner" is "your user name", "Group" is "Staff" and "Access" for Owner, Group and Others is "Read & Write" and click the "Apply to Enclosed Items" button. I basing this information on what the Ownership & Permissions are for each of the folders in my system.
    Open Cocktail (I'm using version 3.6.5). Once the app is open (you must enter an administrator's user name and password) click on the "Files" button, then click on the "Links" button. Where it says "Create Symbolic Link" click on the "Choose" button. Navigate to the iCal folder (Hard Disk > Users > Shared > iCal) and click "Choose" again. In the "Save As" box that appears enter "iCal", then navigate to the Application Support folder in your Home folder (your user name > Library > Application Support) and click "Save". Quit Cocktail and open iCal. You should see all of your calendars as you did before.
    Log in under each additional User, move that User's iCal folder (user name > Library > Application Support > iCal) onto the Desktop, then create another Symbolic Link to replace it, using Cocktail as described above. In each case you should see the same calendar information as when you were logged in under your user name. As a test, add a New Event or To Do in iCal under one user, log out and back in under another user and you should see the changes when you open iCal.
    Once everything appears to be working, you can delete the iCal folders from each User's Desktop.
    As an additional maintenance measure, use Disk Utility to repair Disk Permissions.
    Unfortunately, if each User has his/her own calendars in iCal they will not be in the shared calendars. Only the calendars in the first iCal folder used to set up the shared folder will be available and I don't know of any way to merge or combine the other user's calendars into one.
    Hope this helps and good luck!

    Unfortunately, if each User has his/her own calendars in iCal they will not be in the shared calendars. Only the calendars in the first iCal folder used to set up the shared folder will be available and I don't know of any way to merge or combine the other user's calendars into one.
    If every user first exports their calendars (with unique names) and then the "First" user imports them, before all the other set up, everyone's calendar will be there.
    Also, iCalShare lets you publish and subscribe on a computer or across a local network, without having to let everyone see and edit all your calendars.

  • Share XSD schemas among BPEL projects?

    Hello,
    Does anyone know how to share XSD schemas among BPEL projects?
    I am using the GS1 XML Standard for a project. But I just want to maintain only one copy of this consolidated XML schema. Now I have to copy the whole schema folder to each BPEL project to use them.
    By the way, I can assign the application directory for the schema by using "../../something", but I can't assign the absolute path in WSDL. And how about during the deployment?
    Thanks and regards,
    Kerr
    Edited by: Kerrs on 24/03/2009 15:29

    You can copy XSD's into <ORACLE_SOA_HOME>/bpel/system/xmllib folder and access them using the following url:
    http://<HOST NAME>:<PORT>/orabpel/xmllib/<XSD PATH>
    for example - http://localhost:8888/orabpel/xmllib/Mail.xsd
    Regards,
    Dharmendra
    http://soa-howto.blogspot.com

  • How to share on CC with Team members and other problems

    I had a CC for Team account, then got a deal to add seats at a discount, I added 2 more. I had to change my password and give a new e-mail address to get this deal. When I log in using my New ID all my files are gone. I log in with my Old ID my files and web sites are there no team members, added my OldID to the new Teams account and made me an administrator. Now when I log in with my OldID I can see my file and team members one of them is me with a new ID and the other is a client. I want to get rid of one of me I prefer the new one but I can't I can only delete the OldID and I lose my web site and all my files. Now the only reason I did this was to let my client see the files instead of selecting one page at a time and sending a link I thought they could go to their folder and look at the pages as they are being designed and edited. But there is no method to share with other team members. I re-watch the Max video but nothing they were showing is available in my team CC account. Can someone Help me out Please?

    New: Creative Cloud for teams. Join now | Read online
    We hope your team is enjoying their Creative Cloud for teams membership. From now through June 28, you can add more seats for only US$39.99/month per seat — for up to 24 months.
    Your Adobe® Creative Cloud™ for teams membership will have some amazing new things to offer. Brand-new creative apps, like Adobe Photoshop® CC, Illustrator® CC, and 13 other favorites — with hundreds of new features that help everyone create their greatest work. Plus, 100GB of storage for each team member. And now, a lower price for both new and existing seats.
    Keep everyone on the same page, working on the latest versions of the same apps, and sharing files from any device.
    You've made the right choice. New creative software innovation will be delivered exclusively to Creative Cloud members. Add more seats of Creative Cloud for teams today.
    Special offer.
    Add new seats before
    June 28, 2013, for just US$39.99/month per seat — AND get a first annual renewal price of US$39.99/month per seat.
    Learn more ›
    Share with your friends
    * VOID WHERE PROHIBITED OR RESTRICTED BY LAW. If you own Creative Suite through an Adobe volume licensing program, save US$30.00 per seat when you enroll in the Adobe Value Incentive Plan (VIP) and purchase Creative Cloud for teams annual plan membership (12-month contract required) before 11:59 pm on June 28, 2013. Creative Cloud for teams regular price: US$69.99. Offer(s) available only to eligible Creative Suite subscribers (CS3 or later) who enroll in the Adobe Value Incentive Plan (VIP) and who purchase Creative Cloud for teams through authorized Adobe corporate resellers. Offer discounts are only valid for up to two years. Offer discounts may not be applied retroactively. Additional terms and conditions may apply. Residents or persons in embargoed countries or countries subject to U.S. or local export restrictions are not eligible. All prices quoted are estimated street prices only. Offer and prices are subject to change without notice and exclude shipping, handling and any applicable sales tax. Offer may not be assigned, exchanged, sold, transferred, or combined with any other discount or offer, or redeemed for cash or other goods and services. Adobe, the Adobe logo, Acrobat, Creative Cloud, the Creative Cloud logo, Creative Suite, Illustrator, and Photoshop are either registered trademarks or trademarks of Adobe Systems Incorporated in the United States and/or other countries. All other trademarks are the property of their respective owners. © 2013 Adobe Systems Incorporated. All rights reserved. To ensure future delivery of email, please add [email protected] to your address book, contacts or safe sender list. PLEASE DO NOT REPLY TO THIS MESSAGE. To obtain information on how to contact Adobe, visit the web at:www.adobe.com/misc/comments.html, or call 800-833-6687. This is a marketing email from Adobe Systems Incorporated, 345 Park Avenue, San Jose, CA 95110 USA.
    Click here to unsubscribe. Your privacy is important to us. Please review Adobe's Privacy Policy.
    Too many newsletters? You can unsubscribe or better yet, schedule automatic cleanup. 

  • Datalogging and Supervisory Control : how to share data among LabVIEW applications on the same network?

    I'm new to DSC. Is there an example program or article about how to share data (live data and data saved after running a program) among LabVIEW (using DSC) that is very basic? I would like to share live data and test reult data (eg. excel) among computers on the same network (may be LAN). Does sharing data over a network by using DSC makes whole system (all computers) down when one computer is locked up?

    Hi,
    The easiest way to network DSC data is using "network tags". The way you do it is by simply configuring the server PC as you normally would do for a local application.
    Then from a remote compute, which we can call a client computer you can go to Tag Configuration Editor and option "File >> Import Network Tags.."
    In the window that opens up you can hit the browse buttom and navigate to your server computer, select the .scf file you want to have and hit the buttom import.
    Save the "client .scf" file locally and now you have in the client the same configuration you have in the server and your data is networked, from there on is just a matter of manipulating the data.
    I hope it helps
    Andre Oliveira

  • How to share iPhoto among user accounts

    Could someone please tell me how to share the iPhoto pictures among all user accounts on my iMac? Thanks.

    The iPhoto Application stays in the Applications Folder.
    The iPhoto Library gets moved to the external disk.

  • HT4914 How does the family sharing allow members to share music in iTunes Match?

    Same as title, How does the family sharing allow members to share music in iTunes Match?

    Yes, you can stream or transfer music ripped from CDs to other computers via Home Sharing.

  • How can I share a printer among a wired Mac and a wireless laptop?

    I find this extremely frustrating, but I can't figure out how to share my printer for the life of me.
    My Mac Pro is connected to my router and when my girlfriend is here she connects her computer to the internet via my router wirelessly/WiFi. She has 10.4.0 and I have 10.5.5. On both computers printing sharing is enabled. Shouldn't one of our computers be able to see the other on a network? Or is there something I'm completely missing? All I want is for her to SOMEHOW connect to my computer so she can print stuff and I dont have to go behind my computer, unplug the USB, and plug it into hers. Even though I am in the printer discussion area, I even want to be able to share files too. It should be relatively simple but I don't understand what I'm supposed to do and I can't even find any sort of "setup wizard" that directs me in the direction to go. Sorry but I've been using Windows for 10 years and I'm just completely lost in the mac world now Thanks

    Hello and welcome to the Apple forums.
    With regards to sharing your printer, you need to open System Preferences > Sharing and then tick printer sharing. In the right hand pane you will also be able to select which printer to share (if you only have one then it will probably already be selected). Now your partner should be able to open their System Preferences > Print and Fax and click the + button to add a printer. If they then select the Default browser view, your printer share should be visible. If it is not visible, then please reply as there may be other factors that are causing this.
    Also, with regards to file sharing, while you were in System Preferences > Sharing you would have seen Personal File Sharing. Enable this setting so that the other Mac can see your Mac on the network. If they select the Guest account when connecting to your Mac, the will have by default access to your Public folder for viewing documents and your Drop Box for sending files to you.
    One last thing. You mentioned the other Mac running 10.4.0. The latest version of 10.4 (Tiger) is 11. So, if this Mac is really at 10.4.0, then you may want to update it as this may contribute to compatibility issues between the two Mac's.
    PaHu

  • How to share a file system among two differant containers

    Hi there,
    Is there anyway to share a filesystem among two containers? If so what makes the difference if the storage is from 1) SAN 2) NAS and 3) Internal Storage.
    Thanks,
    John

    johnmighty wrote:
    Hi folks,
    Thanks for your valuable quotes and suggestions.
    Here is my requirement, a FS is mounted in zone which comes form SAN and oracle installed in it, Now for R&D purpose we want create another container and install a newer version of oracle. In this case can we share the storage between those two containers?Not easily. You'd have similar issues if you had two independent machines that you wanted to see the same SAN storage.
    If you want to solve this problem via a way that leverages the zone aspect, you have to swap the mount from being in the non-global zone as a direct mount, to being in the global zone and with an lofs mount to the non-global zones.
    If these were independent machines, you could make one of them do the mount and serve the data via NFS to the other machine. But that's not available to non-global zones.
    Darren

  • Can't share, unshare or add members to a shared calendar. What happened

    I am the owner of a shared calendar but the option to unshare, share or add new members is no longer there. How do I get it back? I set up a family calendar a few years back and all of my family use it to communicate with the other member. I now need to add a new member but when I go through the procedure to add a person the option is not available. In the calendar edit screen it shows me as the owner of the calendar both on my iPad, iPhone and online using my PC. ONline it shows all of the invitees in a list as it should but there is no option to change sharing status or add a new member. As an experiment I added a new calendar and I can set the sharing status on it and add new members.
    What has happened to my ownership status on this calendar and how do I get it back?

    TheMurf1947,
    Not sure if it relevant but I just updated my iPad 4 to IOS 8.1.2 and now I keep getting 'share my location unavailable' when I try and switch the share my location ability off.  I dont have the same issue with my Iphone 5 which is running IOS 8.1.1.  Seems they may have either introduced another bug.
    Its in Privacy --> Location Services --> Share my Location.

Maybe you are looking for

  • Option To Insert "/" Between Hierarchical Keywords

    "Treat "/" as a keyword separator" works for me when importing on Vista. I would like to see it added as an option for export. For example, I have keyword hierarchies of Places/National Parks/Yellowstone and Wildlife/Bears/Grizzly in both LR and my V

  • Is there anything like HOST command in Forms in Reports ??

    Hello everybody Is there any command in reports like a HOST command in Forms through which I can call a system command. My goal is I want to invoke a shell script from my report that will run in the background, do few things and come back to the repo

  • I am unable to connect to my wifi after upgrading to ios 7 can anyone help?

    hi all can anyone help me find out how to connect to my wifi after i upgraded my fone to ios7,ive tried logging on to my account but still no connection??

  • Mouse Event Problem

    I need to implement the pseudocode below into a method called cursorNearVertex (xMouse, yMouse). This method should return either a true or false value depending on what part of the canvas the user clicks on. If the user clicks near a graphical verte

  • Associating BI Publisher rerport to a View belonging to different bus Obj.

    Hi All, Is it possible to associate a BI Publisher report to a view that is based on a different BO?? Should the Report's IO and the Associated View's Business Object be the same?? If they can be different,. how is it possible to add them?? Appreciat