• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

How to access SerialPort in Applets using jSSC library

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a requirement to access serial ports from Applets. For this using jssc.jar library and try to get the list of available ports. When I am doing this getting the below exception

Exception in thread "Thread-23" java.lang.ExceptionInInitializerError
at jssc.SerialPortList.<clinit>(SerialPortList.java:43)
at SerialIO.fetchSerialPorts(SerialIO.java:204)
at Applet.startJavaScriptListener(Applet.java:174)
at Applet.mav$startJavaScriptListener(Applet.java:36)
at Applet$1.run(Applet.java:105)
at java.security.AccessController.doPrivileged(Native Method)
at printer.Applet.run(Applet.java:100)
at java.lang.Thread.run(Unknown Source)
Caused by: java.security.AccessControlException: access denied ("java.util.PropertyPermission" "user.home" "read")
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at sun.awt.AWTSecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
at java.lang.System.getProperty(Unknown Source)
at jssc.SerialNativeInterface.<clinit>(SerialNativeInterface.java:85)
... 8 more

How should I modify the java.policy to get out of this exception. Do I need to use anything else other than this jar.

I am using java 1.6.0_27 and Windows 7

Please help me in resolving this issue.

Thanks,
Eshwari
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer to your question is in the stack trace:

access denied ("java.util.PropertyPermission" "user.home" "read")


In your policy file you need to set the property permission for user.home to allow read access.

Something like:

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To handle permission, scm uses tmp folder. The scm is an alternative library to rxtx/javaxcom.
Wiki : http://www.embeddedunveiled.com/
Repository : https://github.com/RishiGupta12/serial-communication-manager
Video : https://www.youtube.com/watch?v=fYLQbelGunQ

It supports RS-232 control signals handshaking, monitoring and has been ported to Linux, MAC, Solaris and Windows operating system. It is consistent, portable, efficient, reliable, testable, extensible, modifiable, scalable library.
 
A day job? In an office? My worst nightmare! Comfort me tiny ad!
ScroogeXHTML 9.0 - RTF to HTML5 and XHTML converter
https://coderanch.com/t/731949/ScroogeXHTML-RTF-HTML-XHTML-converter
    Bookmark Topic Watch Topic
  • New Topic