Two or more Java Process can not use SerialComManager

18 views
Skip to first unread message

Pratap Tripathy

unread,
Feb 18, 2016, 6:28:05 AM2/18/16
to serial communication manager
I have written a program that allow you to select a port and read/writes to it. First time I start the program it works fine. If I start the 2nd process to communicate with another port I get error:

Caused by: java.io.FileNotFoundException: C:\Users\ADMINI~1\AppData\Local\Temp\scm_tuartx1\windows_1.0.4_x86_64.dll (The process cannot access the file because it is being used by another process)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:206)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:156)
    at com.embeddedunveiled.serial.internal.SerialComPortJNIBridge.loadNativeLibrary(SerialComPortJNIBridge.java:295)

rishi gupta

unread,
Feb 18, 2016, 6:47:35 AM2/18/16
to Pratap Tripathy, serial communication manager
There are 2 constructors; SerialComManager() and SerialComManager(String directoryPath, String loadedLibName). First constructor will extract windows_1.0.4_x86_64.dll file in temp folder. Now because you are running two separate process, 2nd process will throw this exception because 1st is already using this file.

Use this constructor SerialComManager(String directoryPath, String loadedLibName) to provide separate location/file names to be used. Think it this way. Assume you package SCM in your jar and another vendor also packaged SCM in his jar. Now both will use temp folder and 2nd vendor will fail. To address such scenario, this 2nd constructor is used.

Read javadocs for details.

--
You received this message because you are subscribed to the Google Groups "serial communication manager" group.
To unsubscribe from this group and stop receiving emails from it, send an email to serial-communication...@googlegroups.com.
To post to this group, send email to serial-communi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/serial-communication-manager/f8aa3a35-d2d2-4637-9bb6-92ca06d9d336%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andreas Kuhtz

unread,
Mar 13, 2016, 9:28:35 AM3/13/16
to rishi gupta, serial communication manager
Hi Rishi,

I think it would be a good option to let the user just specify an application name (a string) and the directory path and loadedLibName is calculated by the application name and the directory is created automatically.
Currently I have to create the directory that is passed to the constructor.
What do you think?

Regards,
Andreas

Rishi Gupta

unread,
Mar 13, 2016, 10:05:21 AM3/13/16
to serial communication manager, gup...@gmail.com
Few things we need to discuss.

- How we will decide directory path on user system (unix and non-unix).
- How we are going to deal with security (restrictions that might have been imposed by JVM, antivirus, operating system, admin policy etc).
- What if by chance on user system 2 applications have same name.
- What if 2 independent 3rd party application which packaged scm.jar into their jar try to use same folder.


On Sunday, March 13, 2016 at 6:58:35 PM UTC+5:30, Andreas Kuhtz wrote:
Hi Rishi,

I think it would be a good option to let the user just specify an application name (a string) and the directory path and loadedLibName is calculated by the application name and the directory is created automatically.
Currently I have to create the directory that is passed to the constructor.
What do you think?

Regards,
Andreas
2016-02-18 12:47 GMT+01:00 rishi gupta <>:
There are 2 constructors; SerialComManager() and SerialComManager(String directoryPath, String loadedLibName). First constructor will extract windows_1.0.4_x86_64.dll file in temp folder. Now because you are running two separate process, 2nd process will throw this exception because 1st is already using this file.

Use this constructor SerialComManager(String directoryPath, String loadedLibName) to provide separate location/file names to be used. Think it this way. Assume you package SCM in your jar and another vendor also packaged SCM in his jar. Now both will use temp folder and 2nd vendor will fail. To address such scenario, this 2nd constructor is used.

Read javadocs for details.
On Thu, Feb 18, 2016 at 4:58 PM, Pratap Tripathy <> wrote:
I have written a program that allow you to select a port and read/writes to it. First time I start the program it works fine. If I start the 2nd process to communicate with another port I get error:

Caused by: java.io.FileNotFoundException: C:\Users\ADMINI~1\AppData\Local\Temp\scm_tuartx1\windows_1.0.4_x86_64.dll (The process cannot access the file because it is being used by another process)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:206)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:156)
    at com.embeddedunveiled.serial.internal.SerialComPortJNIBridge.loadNativeLibrary(SerialComPortJNIBridge.java:295)

--
You received this message because you are subscribed to the Google Groups "serial communication manager" group.
To unsubscribe from this group and stop receiving emails from it, send an email to serial-communication-manager+unsub...@googlegroups.com.
To post to this group, send email to serial-communication-manager@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "serial communication manager" group.
To unsubscribe from this group and stop receiving emails from it, send an email to serial-communication-manager+unsub...@googlegroups.com.
To post to this group, send email to serial-communication-manager@googlegroups.com.

Andreas Kuhtz

unread,
Mar 13, 2016, 10:39:33 AM3/13/16
to Rishi Gupta, serial communication manager
Hi Rishi,

2016-03-13 15:05 GMT+01:00 Rishi Gupta <gup...@gmail.com>:
Few things we need to discuss.

- How we will decide directory path on user system (unix and non-unix).
Same procedure as with no-arg constructor. Just make it easier but not use the default name for the unpacked lib. Maybe skip the noarg constructor in favour of the the one arg constructor.
 
- How we are going to deal with security (restrictions that might have been imposed by JVM, antivirus, operating system, admin policy etc).
For security restrictions the 2-arg c'tor as it is now is fine. No need to change it.
 
- What if by chance on user system 2 applications have same name.
- What if 2 independent 3rd party application which packaged scm.jar into their jar try to use same folder.
In this case the 2-arg c'tor as it is now is fine. If start 2 instances of the application is not allowed anyway (e.g. with lockfile) there would be no need to support it.

BTW: I got a CP210X, will try to use it later with the lib you provided  :-)

Regards,
Andreas
 

On Sunday, March 13, 2016 at 6:58:35 PM UTC+5:30, Andreas Kuhtz wrote:
Hi Rishi,

I think it would be a good option to let the user just specify an application name (a string) and the directory path and loadedLibName is calculated by the application name and the directory is created automatically.
Currently I have to create the directory that is passed to the constructor.
What do you think?

Regards,
Andreas
2016-02-18 12:47 GMT+01:00 rishi gupta <>:
There are 2 constructors; SerialComManager() and SerialComManager(String directoryPath, String loadedLibName). First constructor will extract windows_1.0.4_x86_64.dll file in temp folder. Now because you are running two separate process, 2nd process will throw this exception because 1st is already using this file.

Use this constructor SerialComManager(String directoryPath, String loadedLibName) to provide separate location/file names to be used. Think it this way. Assume you package SCM in your jar and another vendor also packaged SCM in his jar. Now both will use temp folder and 2nd vendor will fail. To address such scenario, this 2nd constructor is used.

Read javadocs for details.
On Thu, Feb 18, 2016 at 4:58 PM, Pratap Tripathy <> wrote:
I have written a program that allow you to select a port and read/writes to it. First time I start the program it works fine. If I start the 2nd process to communicate with another port I get error:

Caused by: java.io.FileNotFoundException: C:\Users\ADMINI~1\AppData\Local\Temp\scm_tuartx1\windows_1.0.4_x86_64.dll (The process cannot access the file because it is being used by another process)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:206)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:156)
    at com.embeddedunveiled.serial.internal.SerialComPortJNIBridge.loadNativeLibrary(SerialComPortJNIBridge.java:295)

--
You received this message because you are subscribed to the Google Groups "serial communication manager" group.
To unsubscribe from this group and stop receiving emails from it, send an email to serial-communication...@googlegroups.com.
To post to this group, send email to serial-communi...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "serial communication manager" group.
To unsubscribe from this group and stop receiving emails from it, send an email to serial-communication...@googlegroups.com.
To post to this group, send email to serial-communi...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "serial communication manager" group.
To unsubscribe from this group and stop receiving emails from it, send an email to serial-communication...@googlegroups.com.
To post to this group, send email to serial-communi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/serial-communication-manager/8ac859cf-0372-4279-8e2a-3c70c99c02ef%40googlegroups.com.

rishi gupta

unread,
Mar 14, 2016, 7:01:06 AM3/14/16
to Andreas Kuhtz, serial communication manager
---------------------------------                           ----------------------------------
| module A (priviledged) |  ~~~~~~~~~~~ |module B (uses scm.jar)|
---------------------------------                           ---------------------------------

In networked applications or security sensitive applications, typically, applications will have different level of abstractions and privileged modules. How are we going to handle scenario where the module with scm.jar does not have permissions for disc access.

May be in 2-arg c'tor we add boolean createDirectory argument. If it is true SCM will create directory otherwise it is left to the application.

Andreas Kuhtz

unread,
Mar 14, 2016, 7:43:01 AM3/14/16
to rishi gupta, serial communication manager
Hi Rishi,

rishi gupta <gup...@gmail.com> schrieb am Mo., 14. März 2016 um 12:01 Uhr:
---------------------------------                           ----------------------------------
| module A (priviledged) |  ~~~~~~~~~~~ |module B (uses scm.jar)|
---------------------------------                           ---------------------------------

In networked applications or security sensitive applications, typically, applications will have different level of abstractions and privileged modules. How are we going to handle scenario where the module with scm.jar does not have permissions for disc access.

May be in 2-arg c'tor we add boolean createDirectory argument. If it is true SCM will create directory otherwise it is left to the application.

That would be good!

Regards,
Andreas

rishi gupta

unread,
Mar 14, 2016, 8:52:20 AM3/14/16
to Andreas Kuhtz, serial communication manager
Done adding new parameter and implementation, use latest jar from here https://github.com/RishiGupta12/serial-communication-manager/tree/master/prebuilt-release

Andreas Kuhtz

unread,
Mar 14, 2016, 10:48:48 AM3/14/16
to rishi gupta, serial communication manager
Hi Rishi,

Thank you.

Could you provide ARM native libraries, too?

Regards,
Andreas

rishi gupta

unread,
Mar 14, 2016, 11:42:38 PM3/14/16
to Andreas Kuhtz, serial communication manager
Hi Andreas,

- Which board.
- Which ARM platform (linux/windows)
- Hard float/soft float
- Embedded SE / JVM ?
- Have you build any C source for that board before ?
Reply all
Reply to author
Forward
0 new messages