element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Embedded and Microcontrollers
  • Technologies
  • More
Embedded and Microcontrollers
Embedded Forum swing application error on BBB
  • Blog
  • Forum
  • Documents
  • Quiz
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Embedded and Microcontrollers to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 28 replies
  • Subscribers 484 subscribers
  • Views 3086 views
  • Users 0 members are here
Related

swing application error on BBB

ramanc51
ramanc51 over 10 years ago

Hi all

          I am getting following error while i run my java swing app through linux script, but no error while executing by java -jar myapp.jar on shell, is there any clue to resolve this error

 

java.awt.eventqueue3.run

java.security.accesscontroller.doPrevilidged(native method)

java.security.protectiondomain$javasecurityaccessimpl.dointersection

java.awt.eventqueue.dispatchevent

  • Sign in to reply
  • Cancel

Top Replies

  • clem57
    clem57 over 10 years ago +1
    What is your linux script source?
  • clem57
    clem57 over 10 years ago in reply to ramanc51 +1
    ramanc51 Key message is HeadlessException (Java Platform SE 6) and No X11 DISPLAY variable was set, but this program performed an operati...s it. This means you need X windows environment properly set…
  • mconners
    mconners over 10 years ago in reply to ramanc51 +1
    The one who owns the display is the user that is logged in. You are starting a service as one of the system users, I'm not sure which one, because I don't have access to your system. X11 will prevent users…
Parents
  • clem57
    clem57 over 10 years ago

    What is your linux script source?

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • ramanc51
    ramanc51 over 10 years ago in reply to clem57

    i saved my script in /usr/bin/myscript.sh

     

    #!/bin/bash

    java - jar /home/debian/myapp.jar

     

    trying to execute from my myapp.service that saved on /usr/lib/systemd/system and symliked to /etc/systemd/system

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • ramanc51
    ramanc51 over 10 years ago in reply to ramanc51

    Thanks, for reply, find the complete error below

     

    Feb 18 17:54:23 beaglebone QMServer.sh[1404]: Jar version = RXTX-2.2pre1

    Feb 18 17:54:23 beaglebone QMServer.sh[1404]: native lib Version = RXTX-2.2pre2

    Feb 18 17:54:23 beaglebone QMServer.sh[1404]: Exception in thread "main" java.awt.HeadlessException:

    Feb 18 17:54:23 beaglebone QMServer.sh[1404]: No X11 DISPLAY variable was set, but this program performed an operati...s it.

    Feb 18 17:54:23 beaglebone QMServer.sh[1404]: at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)

    Feb 18 17:54:23 beaglebone QMServer.sh[1404]: at java.awt.Window.<init>(Window.java:536)

    Feb 18 17:54:23 beaglebone QMServer.sh[1404]: at java.awt.Frame.<init>(Frame.java:420)

    Feb 18 17:54:23 beaglebone QMServer.sh[1404]: at java.awt.Frame.<init>(Frame.java:385)

    Feb 18 17:54:23 beaglebone QMServer.sh[1404]: at javax.swing.JFrame.<init>(JFrame.java:189)

    Feb 18 17:54:23 beaglebone QMServer.sh[1404]: at token.TokenUpdaterGUI.main(TokenUpdaterGUI.java:282)

    debian@beaglebone:~$

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • mconners
    mconners over 10 years ago in reply to ramanc51

    In the OP you list the following errors:

    java.awt.eventqueue3.run

    java.security.accesscontroller.doPrevilidged(native method)

    java.security.protectiondomain$javasecurityaccessimpl.dointersection

    java.awt.eventqueue.dispatchevent

     

    then when you state "find the complete error below"

    Feb 18 17:54:23 beaglebone QMServer.sh[1404]: Jar version = RXTX-2.2pre1

    Feb 18 17:54:23 beaglebone QMServer.sh[1404]: native lib Version = RXTX-2.2pre2

    Feb 18 17:54:23 beaglebone QMServer.sh[1404]: Exception in thread "main" java.awt.HeadlessException:

    Feb 18 17:54:23 beaglebone QMServer.sh[1404]: No X11 DISPLAY variable was set, but this program performed an operati...s it.

    Feb 18 17:54:23 beaglebone QMServer.sh[1404]: at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)

    Feb 18 17:54:23 beaglebone QMServer.sh[1404]: at java.awt.Window.<init>(Window.java:536)

    Feb 18 17:54:23 beaglebone QMServer.sh[1404]: at java.awt.Frame.<init>(Frame.java:420)

    Feb 18 17:54:23 beaglebone QMServer.sh[1404]: at java.awt.Frame.<init>(Frame.java:385)

    Feb 18 17:54:23 beaglebone QMServer.sh[1404]: at javax.swing.JFrame.<init>(JFrame.java:189)

    Feb 18 17:54:23 beaglebone QMServer.sh[1404]: at token.TokenUpdaterGUI.main(TokenUpdaterGUI.java:282)

     

    they don't show the same errors.

     

    several things

     

    1) In the second set of error messages, it says "no X11 DISPLAY variable set", which is probably why it can't display and gives you awt errors. Could you add a line to your bash script, prior to executing the java command

     

    echo $DISPLAY

     

    and we'll see what that returns

     

    2) Are logged in with a bash shell?

     

    3) Are you running the script as

    bash myscript.sh

     

    or just

     

    myscript.sh

     

    4) change your script

    #!/bin/bash

    echo $DISPLAY

    cd /home/debian

    java - jar myapp.jar

     

    and see if that give a different result

     

    Mike

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • clem57
    clem57 over 10 years ago in reply to ramanc51

    ramanc51

         Key message is HeadlessException (Java Platform SE 6) and No X11 DISPLAY variable was set, but this program performed an operati...s it.

    This means you need X windows environment properly set up inside the bash shell which is normally a text based environment. To overcome this, you will need to start X11 process with the application as startup. Or avoid doing any graphical commands in your source.

    Clem

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • clem57
    clem57 over 10 years ago in reply to ramanc51

    ramanc51

         Key message is HeadlessException (Java Platform SE 6) and No X11 DISPLAY variable was set, but this program performed an operati...s it.

    This means you need X windows environment properly set up inside the bash shell which is normally a text based environment. To overcome this, you will need to start X11 process with the application as startup. Or avoid doing any graphical commands in your source.

    Clem

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
Children
  • mconners
    mconners over 10 years ago in reply to clem57

    clem57 he did say it runs from the command line, so it may just be that the DISPLAY variable is not being passed to the subprocess spawned when he runs the bash script.

     

    he may just have to do an

     

    export DISPLAY=value prior to running the script so that the subprocess has access to it, or add to his .bashrc

     

    Mike

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • ramanc51
    ramanc51 over 10 years ago in reply to mconners

    Hi Mike, on your reply to clem57, you said export DISPLAY=value, here value=?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • mconners
    mconners over 10 years ago in reply to ramanc51

    value would be :0.0 or localhost:0.0 based on what you typed above

     

    so

     

    export DISPLAY=localhost:0.0

     

    Mike

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • ramanc51
    ramanc51 over 10 years ago in reply to mconners

    Hi Mike after changing as you said export DISPLAY=localhost:0.0, i got following error message, QMServer.service is my service to auto start my java app through QMServer.sh

     

    debian@beaglebone:/usr/bin$ sudo systemctl daemon-reload

    debian@beaglebone:/usr/bin$ sudo systemctl start QMServer.service

    debian@beaglebone:/usr/bin$ systemctl status QMServer.service

    QMServer.service - QMServer

          Loaded: loaded (/lib/systemd/system/QMServer.service; enabled)

          Active: failed (Result: exit-code) since Thu, 18 Feb 2016 20:11:56 +0530; 11s ago

         Process: 1936 ExecStart=/usr/bin/QMServer.sh (code=exited, status=1/FAILURE)

          CGroup: name=systemd:/system/QMServer.service

     

    Feb 18 20:11:56 beaglebone QMServer.sh[1936]: at java.awt.GraphicsEnvironment.createGE(GraphicsEnvironment.java:103)

    Feb 18 20:11:56 beaglebone QMServer.sh[1936]: at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEn...a:82)

    Feb 18 20:11:56 beaglebone QMServer.sh[1936]: at sun.awt.X11.XToolkit.<clinit>(XToolkit.java:126)

    Feb 18 20:11:56 beaglebone QMServer.sh[1936]: at java.lang.Class.forName0(Native Method)

    Feb 18 20:11:56 beaglebone QMServer.sh[1936]: at java.lang.Class.forName(Class.java:264)

    Feb 18 20:11:56 beaglebone QMServer.sh[1936]: at java.awt.Toolkit$2.run(Toolkit.java:860)

    Feb 18 20:11:56 beaglebone QMServer.sh[1936]: at java.awt.Toolkit$2.run(Toolkit.java:855)

    Feb 18 20:11:56 beaglebone QMServer.sh[1936]: at java.security.AccessController.doPrivileged(Native Method)

    Feb 18 20:11:56 beaglebone QMServer.sh[1936]: at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:854)

    Feb 18 20:11:56 beaglebone QMServer.sh[1936]: at sun.swing.SwingUtilities2.getSystemMnemonicKeyMask(SwingUtilities2....2020)

    debian@beaglebone:/usr/bin$

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • mconners
    mconners over 10 years ago in reply to ramanc51

    Yeah, I don't think that is going to work, you are going to have an issue if you are trying to start this as a service that's running as a different user than the user who "owns" the display.

     

    That's an X11 security thing. It has been a long time since I have dealt with those kinds of issues, so without having the exact environment in front of me and being able to debug it, I'm not sure I can help much more.

     

    two things to test though

     

    temporarily, before starting the service type xhost +, at the command line, this can pose a security risk, but it will open your display to any user until you exit X, or type xhost -

     

    second, export the DISPLAY variable in your script

    meaning at the top of your script add

     

    export DISPLAY=localhost:0.0

     

    you can try that

     

    Mike

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • ramanc51
    ramanc51 over 10 years ago in reply to mconners

    No luck mike, on your reply you said you are going to have an issue if you are trying to start this as a service that's running as a different user than the user who "owns" the display.

     

    I don't like or want to try start service that's running as a different user than the user who "owns" the display, please let know the way to auto start my service who own display, please share me step to start my service properly without X-server issue.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • mconners
    mconners over 10 years ago in reply to ramanc51

    The one who owns the display is the user that is logged in. You are starting a service as one of the system users, I'm not sure which one, because I don't have access to your system. X11 will prevent users from displaying things on your desktop unless you give them permission. Nothing is going to display unless the x server is started prior to the execution of the program.

     

    There are ways to change the ownership of a process after it starts, at least there is from c, i'm not sure about java.

     

    This is a problem that has been solved before, hopefully I've given you enough info to formulate google queries that will help you achieve the final steps.

     

     

    Look into the commands I had you type

    xhost

    export DISPLAY

     

    since your program runs from the command line it seems pretty clear to me that the issue is going to be one of a few things

     

    either the program has no permission to access the DISPLAY

    the program or the environment doesn't know which DISPLAY to acess

    or it's a timing issue from when the application starts and the xserver is started

     

     

    Mike

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • clem57
    clem57 over 10 years ago in reply to mconners

    ramanc51

    If this is a command running on a specific user, see Linux Run Command As Another User or Run as Root User. I think you can start your command when you login, read the part of this How To Launch GUI App With Upstart Script - Ask Ubuntu rather than as the init process.

    Clem

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • ramanc51
    ramanc51 over 10 years ago in reply to clem57

    Thank you Clem, issue is solved by the first link reference, this issue is solved by adding following lines in my  myscript.sh

     

    export DISPLAY=:0.0

     

    cd /home/debian    // my myapp.jar is  here

     

    su - debian  -c ´java -jar myapp.jar´

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • ramanc51
    ramanc51 over 10 years ago in reply to mconners

    Thank you Mike, your guldens was useful to know actual error that i am facing, as you said export DISPLAY is must to run my app.jar without x11 error, finally i found the user own the display by Clem reference then issue is resolved.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube