31. januar 2006 - 21:00
Der er
4 kommentarer og 1 løsning
is it possible to set -D params programaticaly?
Hello! I found a couple of examples of JMS-code. Most of the apps is started with a -D parameter. Is it possible to set this inside of the code? Exampele of -D param could look like: java -Djava.naming.security.credentials=123qwe Best regards Fredrik
Annonceindlæg tema
Forsvar & beredskab
Cybersikkerhed, realtidsdata og robuste it-systemer er blevet fundamentet for moderne forsvar.
31. januar 2006 - 21:23
#1
Have you tried: System.setProperty("java.naming.security.credentials", "123qwe");
31. januar 2006 - 21:24
#2
BTW, if this is your JMS question, then a file jndi.properties in classpath with the properties you need should be fine (and more flexiable than hardcoding)
01. februar 2006 - 10:00
#3
Hello! If I'm right I may set this in the Context like: java.util.Properties properties = loadProperties("jmslabb/jndi.properties"); jndiContext = new InitialContext(properties); public static java.util.Properties loadProperties(String fileName) { try { java.util.Properties properties = new java.util.Properties(); properties.load(new FileInputStream(fileName)); return properties; } catch(Exception e) { e.printStackTrace(); return null; } } Where the jndi.propretis looks like: java.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory java.naming.provider.url=ldap://xxx.xxx.xxx.com:7676/ java.naming.security.principal=admin java.naming.security.credentials=xxxxxxxx javax.jms.QueueConnectionFactory An other way is to have the jndi.properties file in the classpath. Best regards Fredrik
01. februar 2006 - 10:02
#4
Hello Arne! I just answered it my self! Please give a svar so I can reward you!! Best regards Fredrik
01. februar 2006 - 17:02
#5
.
Kurser inden for grundlæggende programmering