Need to specify class name in environment or system property, or as an applet parameter, or in an ap
2012-03-28 16:33
489 查看
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at Chat.<init>(Chat.java:56)
at Chat.main(Chat.java:22)
这是《Java消息服务》里第二章的程序编译出的错,哥可是完完整整按照书本指示来做的。问题的缘由是没有找到jndi.properties文件。
我可在工程所在目录(即有.classpath),src目录下都放了jndi.properties,可还是用eclipse编译总是出错。
但是命令行执行:javac Chat.java却可以执行,且编译成功 & 运行成功。
eclipse怎么了???
不过如果非要在eclipse下编译执行的话,这暂时有个解决方法,可以不用jdni.properties文件,用下面的方法:
有解决方案了再更新。
有新发现:
真的让人很囧,网上查了那么多都说jndi.properties应该放在src目录下,可是放在bin目录下才是王道,至少编译成了。(我是指在eclipse里)
不懂eclipse,不懂classpath
——2012-3-28 21:25:12更新
环境:
OS: Windows XPsp3
Eclipse SDK: Version: 3.5.2 Build id: M20100211-1343
ActiveMQ 5.4.3
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at Chat.<init>(Chat.java:56)
at Chat.main(Chat.java:22)
这是《Java消息服务》里第二章的程序编译出的错,哥可是完完整整按照书本指示来做的。问题的缘由是没有找到jndi.properties文件。
我可在工程所在目录(即有.classpath),src目录下都放了jndi.properties,可还是用eclipse编译总是出错。
但是命令行执行:javac Chat.java却可以执行,且编译成功 & 运行成功。
eclipse怎么了???
不过如果非要在eclipse下编译执行的话,这暂时有个解决方法,可以不用jdni.properties文件,用下面的方法:
Properties p = new Properties(); p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory"); p.put(Context.PROVIDER_URL, "tcp://localhost:61616"); p.put(Context.SECURITY_PRINCIPAL, "system"); p.put(Context.SECURITY_CREDENTIALS, "manager"); p.put("connectionFactoryNames", "topicCF"); p.put("topic.topic1", "jms.topic1");
有解决方案了再更新。
有新发现:
真的让人很囧,网上查了那么多都说jndi.properties应该放在src目录下,可是放在bin目录下才是王道,至少编译成了。(我是指在eclipse里)
不懂eclipse,不懂classpath
——2012-3-28 21:25:12更新
环境:
OS: Windows XPsp3
Eclipse SDK: Version: 3.5.2 Build id: M20100211-1343
ActiveMQ 5.4.3
相关文章推荐
- Need to specify class name in environment or system property, or as an applet parameter, or in an ap
- Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.init
- Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: j
- Need to specify class name in environment or system property, or as an applet parameter, or in a
- javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter,
- 在使用jetty配置jndi的时候报错“Need to specify class name in environment or system property, or as an applet pa
- EJB3.0异常总结--- Need to specify class name in environment or system property,
- javax.naming.NoInitialContextException: Need to specify class name in environment or system property
- javax.naming.NoInitialContextException: Need to specify class name in environment or system property
- javax.naming.NoInitialContextException: Need to specify class name in environment or system property
- WLS Exception: Need to specify class name in environment or system property Solution
- WLS Exception: Need to specify class name in environment or system property Solution
- javax.naming.NoInitialContextException: Need to specify class name in environment or system property
- javax.naming.NoInitialContextException: Need to specify class name in environment or system property
- javax.naming.NoInitialContextException: Need to specify class name in environment or system property
- javax.naming.NoInitialContextException: Need to specify class name in XXX解决
- AIDL 编译报can be an out parameter, so you must declare it as in, out or inout原因探究
- AIDL 编译报can be an out parameter, so you must declare it as in, out or inout原因探究
- Compiler Error Message: CS0234: The type or namespace name 'BorderDetails' does not exist in the class or namespace 'Infragistics.WebUI.Shared' (are you missing an assembly reference?)
- Home not found. Define system property "openfireHome" or create and add the openfire_init.xml file to the classpath