tietze111
Posts: 15
Joined: Thu Mar 08, 2012 2:03 pm

Can't change System Property in Java (java -D)

Wed Sep 30, 2015 1:03 pm

Hi,

I tried to follow this Tutorial: http://www.oracle.com/technetwork/artic ... 77662.html

I installed Java and when I execute "java -version" I get the following output:
java version "1.8.0_60"
Java™ SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot™ Client VM (build 25.60-b23, mixed mode)
My problem is that I can't change the system property sun.security.smartcardio.library. It's at the end of the second section (install Java) in the Tutorial.

What I tried is:
java -D sun.security.smartcardio.library=/usr/lib/arm-linux-gnueabihf/libpcsclite.so.1
But I always get this error:
Error: Could not find or load main class sun.security.smartcardio.library=.usr.lib.arm-linux-gnueabihf.libpcsclite.so.1
What did I do wrong?

Thank you in advance and have a nice day,
tietze111

User avatar
xranby
Posts: 539
Joined: Sat Mar 03, 2012 10:02 pm
Contact: Website

Re: Can't change System Property in Java (java -D)

Wed Sep 30, 2015 1:40 pm

tietze111 wrote:...
What I tried is:
java -D sun.security.smartcardio.library=/usr/lib/arm-linux-gnueabihf/libpcsclite.so.1
it is the space between the -D and sun.security.smartcardio.library=/usr/lib/arm-linux-gnueabihf/libpcsclite.so.1 that cause the problem
use

Code: Select all

java -Dsun.security.smartcardio.library=/usr/lib/arm-linux-gnueabihf/libpcsclite.so.1
also check with ldd that libpcsclite.so.1 can load all of its dependencies

Code: Select all

ldd /usr/lib/arm-linux-gnueabihf/libpcsclite.so.1
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby

tietze111
Posts: 15
Joined: Thu Mar 08, 2012 2:03 pm

Re: Can't change System Property in Java (java -D)

Wed Sep 30, 2015 9:01 pm

Thank you for your help! :)

When using the command without the space the following output comes (java command usage help):
java -Dsun.security.smartcardio.library=/usr/lib/arm-linux-gnueabihf/libpcsclite.so.1
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-client to select the "client" VM
-server to select the "server" VM
-minimal to select the "minimal" VM
The default VM is client.

-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A : separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose:[class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
Warning: this feature is deprecated and will be removed
in a future release.
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
Warning: this feature is deprecated and will be removed
in a future release.
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions with specified granularity
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
See http://www.oracle.com/technetwork/java/ ... index.html for more details.
"ldd /usr/lib/arm-linux-gnueabihf/libpcsclite.so.1" gives me the following output:
linux-vdso.so.1 (0x7efa0000)
/usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76f83000)
libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x76f5e000)
librt.so.1 => /lib/arm-linux-gnueabihf/librt.so.1 (0x76f47000)
libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x76f1f000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76de2000)
/lib/ld-linux-armhf.so.3 (0x54b15000)
Does it mean that it can load all dependencies or is there an error?

Best regards,
tietze111

User avatar
xranby
Posts: 539
Joined: Sat Mar 03, 2012 10:02 pm
Contact: Website

Re: Can't change System Property in Java (java -D)

Wed Sep 30, 2015 9:36 pm

tietze111 wrote:Thank you for your help! :)

When using the command without the space the following output comes (java command usage help):
java -Dsun.security.smartcardio.library=/usr/lib/arm-linux-gnueabihf/libpcsclite.so.1
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
...
This is as expected, you have successfully changed a system property in Java using the -D flag and thus solved the question you asked.
however you have not specified what program to run!

The tutorial only mention that
"Note: The source code for the examples shown in this article is available at https://bitbucket.org/johanvos/javafx-pi-nfc "

it is unfortunate that the tutorial assume everyone know what to do with the sourcecode
i can only give you a quick outline what you need to do since I have never tested compile or use this project:
You need to
1.checkout the source-code to this example project using mercurial,
2. compile it using maven and then
3. run the compiled jar!

hg clone https://bitbucket.org/johanvos/javafx-pi-nfc
cd javafx-pi-nfc/NfcPi
mvn compile
java -Dsun.security.smartcardio.library=/usr/lib/arm-linux-gnueabihf/libpcsclite.so.1 -jar some-generated.jar
tietze111 wrote: "ldd /usr/lib/arm-linux-gnueabihf/libpcsclite.so.1" gives me the following output:
linux-vdso.so.1 (0x7efa0000)
/usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76f83000)
libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x76f5e000)
librt.so.1 => /lib/arm-linux-gnueabihf/librt.so.1 (0x76f47000)
libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x76f1f000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76de2000)
/lib/ld-linux-armhf.so.3 (0x54b15000)
Does it mean that it can load all dependencies or is there an error?

Best regards,
tietze111
This means that the libpcsclite.so.1 shared library find its dependencies. This is good news.
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby

Return to “Java”