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 483 subscribers
  • Views 3068 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 mconners

    Thank you mike, yes both error are for different java GUI app but difference is number of GUI elements, prior higher later lower, now my answer

     

    1. echo $DISPLAY added prior to java program, no result same error, but this time one extra line i saw that is :0.0
    2. I do not know which is default shell on BBB, on desktop there is LXTerminal, i am using that
    3. NO, i am not running as you said, i just tested as given bellow

          cd /usr/bin # i stored my script here

          ./myscript.sh

      Both app are working here, i am also tested as following

        cd /usr/bin

        bash myscript.sh,

    it is also working.

     

       4. I added as you said no result

     

    Actually my intention is to start my app automatically after BBB boot for that i did following

     

    i created my myapp.service that saved on /usr/lib/systemd/system and symliked to /etc/systemd/system     H

    • 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
  • mconners
    mconners over 10 years ago in reply to ramanc51

    Raman Arumugam wrote:

     

     

    Actually my intention is to start my app automatically after BBB boot for that i did following

     

     

    That might be a problem for the reasons clem57 stated, you need to have the xserver started prior to running your program.

     

    Raman Arumugam wrote:

     

    1. NO, i am not running as you said, i just tested as given bellow

          cd /usr/bin # i stored my script here

          ./myscript.sh

      Both app are working here, i am also tested as following

        cd /usr/bin

        bash myscript.sh,

    it is also working.

     

    I'm now confused, is the script working now?

     

    also, try typing

    echo $SHELL

    to see if it tells you which shell you are running

     

    or if that doesn't produce anything

    grep <your username> /etc/passwd

     

    I think you had indicated you are using user debian, so

     

    grep debian /etc/passwd

     

    the last entry will tell you your default shell

     

    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
  • ramanc51
    ramanc51 over 10 years ago in reply to mconners

    For command grep debian /etc/passwd, i got following message

    debian:x:1000:1000:Demo User:/home/debian:bin/bash

    • 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
  • mconners
    mconners over 10 years ago in reply to ramanc51

    That means by default you are running the bash shell, that's good, I just wanted to verify

    • 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
Reply
  • 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
Children
  • 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
  • clem57
    clem57 over 10 years ago in reply to ramanc51

    Great news! Please share your project here when you get the chance!

    Clem

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

    sure, but on later i share my project, i need on more guide i want to load my usb-serial converter with specified name that given below, i created my 81-usb-serial.rules in /etc/udev/rules.d, but this rules is not loaded, it always load ttyUSB0/1 or ttyUSB1/0

     

    SUBSYSTEM=="tty", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", ATTRS{serial}=="DJJHDH", SYMLINK+="USB-RS232"

    SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="A6008isP", SYMLINK+="USB-RS422"

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

    Raman Arumugam wrote:

     

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

    Duh. Of course, I can't believe I did't think of that image. I guess I was too focused on the X issues. Glad you got it sorted out.

     

     

    Mike

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

    OMG! ramanc51

         imagePlease do not change because this area is related to driver code that which expects names to be in a known form. Linux is a beast allowing tons of things to change, Even though it can, you must be a developer knowing what source does to change it.

    Clem

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

    clem57 , It seems like adding the symlink attribute should be OK.

     

    Refer to this guide and search for symlink

    Writing udev rules

    "

    KERNEL=="hdc", SYMLINK+="cdrom cdrom0"

    The above rule is probably more typical of the types of rules you might be writing. It creates two symbolic links at /dev/cdrom and /dev/cdrom0, both of which point at /dev/hdc. Again, no NAME assignment was specified, so the default kernel name (hdc) is used."

     

    Mike

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

    ramanc51 Since this is a different issue, it should probably be moved into a new thread. That helps people find it in the future.

     

    Mike

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

    OK, i posted on separate thread as udev rules error on BBB with more details

    • Cancel
    • Vote Up 0 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