How come this code works when I run it normally in Android Studio as Java, but as soon as I run it as an app it shows me a NullPointerExcception? The 2019 Stack Overflow Developer Survey Results Are InException: com.ibm.mq.MQException: MQJE001: Completion Code 2, Reason 2009How to make an MQ app exe to run continously?java code to catch mqrc 2009 and 2059 errorsError when running .NET app from AutoSysBouncing Out Of Method In IBM Websphere Studio Enterprise Developer - Java CodeWebsphere MQ asynchronous put not workingWebSphere MQ error MQRC_NOT_AUTHORIZED 2035 even with CHLAUTH(DISABLED)How to set message expiry in WebSphere MQ (queue) by Java code ( not by JMS API - time to Live )How to show MQ client list by Java?Accessing IBM MQ 8 using JMS with user but without passwordHow MQ Client like Java Client listen messages from MQ Server running ServerConn Channel

Why not take a picture of a closer black hole?

I am an eight letter word. What am I?

Is it safe to harvest rainwater that fell on solar panels?

Straighten subgroup lattice

Accepted by European university, rejected by all American ones I applied to? Possible reasons?

How to obtain a position of last non-zero element

What do hard-Brexiteers want with respect to the Irish border?

Likelihood that a superbug or lethal virus could come from a landfill

Cooking pasta in a water boiler

Mathematics of imaging the black hole

For what reasons would an animal species NOT cross a *horizontal* land bridge?

Pokemon Turn Based battle (Python)

Keeping a retro style to sci-fi spaceships?

How to notate time signature switching consistently every measure

Can you cast a spell on someone in the Ethereal Plane, if you are on the Material Plane and have the True Seeing spell active?

The phrase "to the numbers born"?

How to type a long/em dash `—`

Is there a way to generate a uniformly distributed point on a sphere from a fixed amount of random real numbers?

Falsification in Math vs Science

Is Cinnamon a desktop environment or a window manager? (Or both?)

Loose spokes after only a few rides

Can a flute soloist sit?

Geography at the pixel level

Button changing its text & action. Good or terrible?



How come this code works when I run it normally in Android Studio as Java, but as soon as I run it as an app it shows me a NullPointerExcception?



The 2019 Stack Overflow Developer Survey Results Are InException: com.ibm.mq.MQException: MQJE001: Completion Code 2, Reason 2009How to make an MQ app exe to run continously?java code to catch mqrc 2009 and 2059 errorsError when running .NET app from AutoSysBouncing Out Of Method In IBM Websphere Studio Enterprise Developer - Java CodeWebsphere MQ asynchronous put not workingWebSphere MQ error MQRC_NOT_AUTHORIZED 2035 even with CHLAUTH(DISABLED)How to set message expiry in WebSphere MQ (queue) by Java code ( not by JMS API - time to Live )How to show MQ client list by Java?Accessing IBM MQ 8 using JMS with user but without passwordHow MQ Client like Java Client listen messages from MQ Server running ServerConn Channel



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















It works perfectly fine when it's run normally as a java code, but as soon as it's run as an app, the queueManager shows NULL. All this code is put inside onCreate(Bundle savedInstanceState). When it's run as java, the debugger actually shows a queueManager value.



void init() 


int openOptions = CMQC.MQOO_INQUIRE









share|improve this question






























    1















    It works perfectly fine when it's run normally as a java code, but as soon as it's run as an app, the queueManager shows NULL. All this code is put inside onCreate(Bundle savedInstanceState). When it's run as java, the debugger actually shows a queueManager value.



    void init() 


    int openOptions = CMQC.MQOO_INQUIRE









    share|improve this question


























      1












      1








      1








      It works perfectly fine when it's run normally as a java code, but as soon as it's run as an app, the queueManager shows NULL. All this code is put inside onCreate(Bundle savedInstanceState). When it's run as java, the debugger actually shows a queueManager value.



      void init() 


      int openOptions = CMQC.MQOO_INQUIRE









      share|improve this question
















      It works perfectly fine when it's run normally as a java code, but as soon as it's run as an app, the queueManager shows NULL. All this code is put inside onCreate(Bundle savedInstanceState). When it's run as java, the debugger actually shows a queueManager value.



      void init() 


      int openOptions = CMQC.MQOO_INQUIRE






      ibm-mq






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 8 at 11:20







      integrationworker

















      asked Mar 8 at 11:07









      integrationworkerintegrationworker

      166




      166






















          2 Answers
          2






          active

          oldest

          votes


















          0














          Is the MQEnvironment a external library? If yes, have you imported it to your android project?






          share|improve this answer























          • Yes, otherwise I wouldn't even be able to run it

            – integrationworker
            Mar 8 at 11:14


















          0














          (1) As I have posted here many times, do NOT use MQEnvironment class as it is not thread safe. Put the connection information into a Hashtable and pass the Hastable to the MQQueueManager class. See here for an example of what I'm talking about.



          (2) Putting "System.exit(2);" in the middle of your code is bad form and that means the finally clause will not be called. Hence, the code will leave open the queue and connection to queue manager.



          (3) In your finally clause, you have the "disconnect" and "close" backwards. You must close the queue before you disconnect from the queue manager.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55061922%2fhow-come-this-code-works-when-i-run-it-normally-in-android-studio-as-java-but-a%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Is the MQEnvironment a external library? If yes, have you imported it to your android project?






            share|improve this answer























            • Yes, otherwise I wouldn't even be able to run it

              – integrationworker
              Mar 8 at 11:14















            0














            Is the MQEnvironment a external library? If yes, have you imported it to your android project?






            share|improve this answer























            • Yes, otherwise I wouldn't even be able to run it

              – integrationworker
              Mar 8 at 11:14













            0












            0








            0







            Is the MQEnvironment a external library? If yes, have you imported it to your android project?






            share|improve this answer













            Is the MQEnvironment a external library? If yes, have you imported it to your android project?







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 8 at 11:10









            HasBertHasBert

            435




            435












            • Yes, otherwise I wouldn't even be able to run it

              – integrationworker
              Mar 8 at 11:14

















            • Yes, otherwise I wouldn't even be able to run it

              – integrationworker
              Mar 8 at 11:14
















            Yes, otherwise I wouldn't even be able to run it

            – integrationworker
            Mar 8 at 11:14





            Yes, otherwise I wouldn't even be able to run it

            – integrationworker
            Mar 8 at 11:14













            0














            (1) As I have posted here many times, do NOT use MQEnvironment class as it is not thread safe. Put the connection information into a Hashtable and pass the Hastable to the MQQueueManager class. See here for an example of what I'm talking about.



            (2) Putting "System.exit(2);" in the middle of your code is bad form and that means the finally clause will not be called. Hence, the code will leave open the queue and connection to queue manager.



            (3) In your finally clause, you have the "disconnect" and "close" backwards. You must close the queue before you disconnect from the queue manager.






            share|improve this answer



























              0














              (1) As I have posted here many times, do NOT use MQEnvironment class as it is not thread safe. Put the connection information into a Hashtable and pass the Hastable to the MQQueueManager class. See here for an example of what I'm talking about.



              (2) Putting "System.exit(2);" in the middle of your code is bad form and that means the finally clause will not be called. Hence, the code will leave open the queue and connection to queue manager.



              (3) In your finally clause, you have the "disconnect" and "close" backwards. You must close the queue before you disconnect from the queue manager.






              share|improve this answer

























                0












                0








                0







                (1) As I have posted here many times, do NOT use MQEnvironment class as it is not thread safe. Put the connection information into a Hashtable and pass the Hastable to the MQQueueManager class. See here for an example of what I'm talking about.



                (2) Putting "System.exit(2);" in the middle of your code is bad form and that means the finally clause will not be called. Hence, the code will leave open the queue and connection to queue manager.



                (3) In your finally clause, you have the "disconnect" and "close" backwards. You must close the queue before you disconnect from the queue manager.






                share|improve this answer













                (1) As I have posted here many times, do NOT use MQEnvironment class as it is not thread safe. Put the connection information into a Hashtable and pass the Hastable to the MQQueueManager class. See here for an example of what I'm talking about.



                (2) Putting "System.exit(2);" in the middle of your code is bad form and that means the finally clause will not be called. Hence, the code will leave open the queue and connection to queue manager.



                (3) In your finally clause, you have the "disconnect" and "close" backwards. You must close the queue before you disconnect from the queue manager.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 8 at 23:23









                RogerRoger

                4,859714




                4,859714



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55061922%2fhow-come-this-code-works-when-i-run-it-normally-in-android-studio-as-java-but-a%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

                    Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

                    Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved