I think it's my classpath?
Hi
Ive got java up and running and have been happily compiling, everything going smoothly. My classpath points to c:\jdk1_3\_work where I keep all my code and I usually have a couple sub directories under that where I keep specific projects ie. c:\jdk1_3\_work\project1 Everything works fine untill I try to create an instance of a class in the same sub directory.
When I try it in the c:\jdk1_3\_work directory it works fine with the 2 class files together, but any sub directory and it complains. I dont want to add to my classpath every sub directory, what can I do?
Sorry, that's the way it works if you don't use packages. Using a package statement is an alternative.
Your directory structure is
c:\jdk1_3\_work <------- this directory is in the classpath
|
project1
Create your .java file in project1 and make the first line "package project1;"
From jdk1_3\_work compile "javac project1\xxxx.java"
From jdk1_3\_work run it "java project1.xxxx"
There are alternative ways to use package statements, but this is the standard.
Similar Messages
-
Javac.exe is not using classpath, while java.exe is.
I'll state the problem, then give my configuration. This does NOT seem to be a duplicate of other problems. I am running Windows NT sp 6a.
INTRO:
javac.exe, java.exe in directory E:\v\bin.
file HelloWorld.java is in directory E:\v\lib\x\y (dir names shortened)
PROBLEM:
Once HelloWorld is compiled (and HelloWorld.class is in E:\v\lib\x\y ), I can run the exact command "java HelloWorld" from ANY directory anywhere and it runs and prints Hello World!.(So java.exe seems to be using classpath.)
However, to compile, the command "javac HelloWorld.java" does not work (say in E:\v). The error message is "cannot read: "HelloWorld.java". I have to provide the full path name for HelloWorld.java, thus: "javac E:\v\lib\x\y\HelloWorld.java". This works, from any directory anywhere. In other words, javac.exe does NOT seem to be using classpath.
CONFIGURATION:
CLASSPATH is set to E:\v\lib\x\y in both system and user environment and ALSO through both javac -classpath and java -classpath. (When I run javac -classpath E:\v\lib\x\y, the list of options is not printed out, and I think this means the classpath is supposed to be set. ) I also tried setting sourcepath for javac, but that did not help.
PATH is set since and the system recognizes the commands "java" and "javac" from any directory anywhere (each brings up the list of options.)
Any thoughts.let's read the documentation first shall we ...
http://java.sun.com/j2se/1.4.1/docs/tooldocs/windows/javac.html
According to it the command line arguments must be file names. The compiler "cannot read HelloWorld.java" because it simply is not in the current working directory. You need to specify a path to the file. It is only after that, "when compiling a source file", that the classpath or sourcepath setting has any effect. -
Can not bind server stubs.
Hi All,
i am strugling for a few days (!) now with a starnge problem
i have created an rmi application and when i run under windows all is well.
when i tried running it under Linux (Red Hat 7.2) and the stubs where not packed in a jar file all is well as
well. BUT - if i pack the stubs in a jar i get an exception :
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: (<name of class>...)
The Exception occour when i try to BIND the stub not when the client is looking for it.
i have set the policy , classpath , and security manager properly obviously since the appliaction is working
ok when the stubs are not packed in a jar. the jar file is at the same directory as the unpacked stubs when
the application is runnig so i dont think it is a classpath issue.
Can anyone please help ? thanx.I don't, sorry. I suppose windows is making a informed guess about the path to the classes. I'm only using linux and Java 1.5 and I have to make sure and expose the interfaces I bind to the rmi registry. Not sure which behavior is supposed to be the correct one.
-
ClassNotFoundException while invoking jax-ws client from OIM 10g
Hi,
As part of integrating FoxT with OIM, I've generated stub classes from FoxT wsdl using wsimport of jax-ws RI. While trying to invoke any webservice method from the process task I am getting below error -
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.thortech.xl.adapterGlue.ScheduleItemEvents.adpFOXTCREATEUSER.FOXTCREATEUSER(adpFOXTCREATEUSER.java:161)
at com.thortech.xl.adapterGlue.ScheduleItemEvents.adpFOXTCREATEUSER.implementation(adpFOXTCREATEUSER.java:106)
at com.thortech.xl.client.events.tcBaseEvent.run(Unknown Source)
at com.thortech.xl.dataobj.tcDataObj.runEvent(Unknown Source)
at com.thortech.xl.dataobj.tcScheduleItem.runMilestoneEvent(Unknown Source)
at com.thortech.xl.dataobj.tcScheduleItem.eventPostInsert(Unknown Source)
at com.thortech.xl.dataobj.tcDataObj.insert(Unknown Source)
at com.thortech.xl.dataobj.tcDataObj.save(Unknown Source)
at com.thortech.xl.ejb.beansimpl.tcProvisioningOperationsBean.addProcessTaskInstance(Unknown Source)
at com.thortech.xl.ejb.beans.tcProvisioningOperationsSession.addProcessTaskInstance(Unknown Source)
at com.thortech.xl.ejb.beans.tcProvisioningOperations_b03yxm_EOImpl.addProcessTaskInstance(tcProvisioningOperations_b03yxm_EOImpl.java:1518)
at Thor.API.Operations.tcProvisioningOperationsClient.addProcessTaskInstance(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at Thor.API.Base.SecurityInvocationHandler$1.run(Unknown Source)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.security.Security.runAs(Security.java:41)
at Thor.API.Security.LoginHandler.weblogicLoginSession.runAs(Unknown Source)
at Thor.API.Base.SecurityInvocationHandler.invoke(Unknown Source)
at $Proxy61.addProcessTaskInstance(Unknown Source)
at com.thortech.xl.webclient.actions.ResourceProfileProvisioningTasksAction.addTask(Unknown Source)
at com.thortech.xl.webclient.actions.ResourceProfileProvisioningTasksAction.dispatchConfirmation(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)
at com.thortech.xl.webclient.actions.tcLookupDispatchAction.execute(Unknown Source)
at com.thortech.xl.webclient.actions.tcActionBase.execute(Unknown Source)
at com.thortech.xl.webclient.actions.tcAction.execute(Unknown Source)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at com.thortech.xl.webclient.security.CSRFFilter.doFilter(Unknown Source)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at com.thortech.xl.webclient.security.SecurityFilter.doFilter(Unknown Source)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(Unknown Source)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(Unknown Source)
at weblogic.servlet.internal.WebAppServletContext.execute(Unknown Source)
at weblogic.servlet.internal.ServletRequestImpl.run(Unknown Source)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Caused by: java.lang.NoClassDefFoundError: Lcom/foxt/mds/ws/generated/AddUserxRolePars;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2291)
at java.lang.Class.getDeclaredFields(Class.java:1743)
at com.sun.xml.bind.v2.model.nav.ReflectionNavigator.getDeclaredFields(ReflectionNavigator.java:249)
at com.sun.xml.bind.v2.model.nav.ReflectionNavigator.getDeclaredFields(ReflectionNavigator.java:58)
at com.sun.xml.bind.v2.model.impl.ClassInfoImpl.findFieldProperties(ClassInfoImpl.java:362)
at com.sun.xml.bind.v2.model.impl.ClassInfoImpl.getProperties(ClassInfoImpl.java:296)
at com.sun.xml.bind.v2.model.impl.RuntimeClassInfoImpl.getProperties(RuntimeClassInfoImpl.java:176)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo(ModelBuilder.java:243)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:98)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:79)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo(ModelBuilder.java:209)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:93)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:79)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:315)
at com.sun.xml.bind.v2.model.impl.RegistryInfoImpl.<init>(RegistryInfoImpl.java:99)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.addRegistry(ModelBuilder.java:357)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:327)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:432)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:286)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:139)
at com.sun.xml.bind.api.JAXBRIContext.newInstance(JAXBRIContext.java:105)
at com.sun.xml.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:153)
at com.sun.xml.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:148)
at com.sun.xml.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:87)
at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:264)
at com.sun.xml.ws.client.WSServiceDelegate.buildRuntimeModel(WSServiceDelegate.java:660)
at weblogic.wsee.jaxws.spi.WLSProvider$ServiceDelegate.buildRuntimeModel(WLSProvider.java:407)
at com.sun.xml.ws.client.WSServiceDelegate.addSEI(WSServiceDelegate.java:648)
at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:330)
at weblogic.wsee.jaxws.spi.WLSProvider$ServiceDelegate.getPort(WLSProvider.java:389)
at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:313)
at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:306)
at javax.xml.ws.Service.getPort(Service.java:92)
at com.foxt.mds.ws.generated.MDSImplService.getMDSImplPort(MDSImplService.java:68)
at com.centurylink.identity.adapter.processtask.FoxTUserOperations.CreateUser(FoxTUserOperations.java:351)
... 60 more
Caused by: java.lang.ClassNotFoundException: com.foxt.mds.ws.generated.AddUserxRolePars
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:283)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:256)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:176)
... 98 more
com.thortech.xl.dataobj.util.tcAdapterTaskException: Lcom/foxt/mds/ws/generated/AddUserxRolePars;
at com.thortech.xl.adapterGlue.ScheduleItemEvents.adpFOXTCREATEUSER.FOXTCREATEUSER(adpFOXTCREATEUSER.java:167)
at com.thortech.xl.adapterGlue.ScheduleItemEvents.adpFOXTCREATEUSER.implementation(adpFOXTCREATEUSER.java:106)
at com.thortech.xl.client.events.tcBaseEvent.run(Unknown Source)
at com.thortech.xl.dataobj.tcDataObj.runEvent(Unknown Source)
at com.thortech.xl.dataobj.tcScheduleItem.runMilestoneEvent(Unknown Source)
at com.thortech.xl.dataobj.tcScheduleItem.eventPostInsert(Unknown Source)
at com.thortech.xl.dataobj.tcDataObj.insert(Unknown Source)
at com.thortech.xl.dataobj.tcDataObj.save(Unknown Source)
at com.thortech.xl.ejb.beansimpl.tcProvisioningOperationsBean.addProcessTaskInstance(Unknown Source)
at com.thortech.xl.ejb.beans.tcProvisioningOperationsSession.addProcessTaskInstance(Unknown Source)
at com.thortech.xl.ejb.beans.tcProvisioningOperations_b03yxm_EOImpl.addProcessTaskInstance(tcProvisioningOperations_b03yxm_EOImpl.java:1518)
at Thor.API.Operations.tcProvisioningOperationsClient.addProcessTaskInstance(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at Thor.API.Base.SecurityInvocationHandler$1.run(Unknown Source)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.security.Security.runAs(Security.java:41)
at Thor.API.Security.LoginHandler.weblogicLoginSession.runAs(Unknown Source)
at Thor.API.Base.SecurityInvocationHandler.invoke(Unknown Source)
at $Proxy61.addProcessTaskInstance(Unknown Source)
at com.thortech.xl.webclient.actions.ResourceProfileProvisioningTasksAction.addTask(Unknown Source)
at com.thortech.xl.webclient.actions.ResourceProfileProvisioningTasksAction.dispatchConfirmation(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)
at com.thortech.xl.webclient.actions.tcLookupDispatchAction.execute(Unknown Source)
at com.thortech.xl.webclient.actions.tcActionBase.execute(Unknown Source)
at com.thortech.xl.webclient.actions.tcAction.execute(Unknown Source)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at com.thortech.xl.webclient.security.CSRFFilter.doFilter(Unknown Source)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at com.thortech.xl.webclient.security.SecurityFilter.doFilter(Unknown Source)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(Unknown Source)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(Unknown Source)
at weblogic.servlet.internal.WebAppServletContext.execute(Unknown Source)
at weblogic.servlet.internal.ServletRequestImpl.run(Unknown Source)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
The class file its complaining about AddUserxRolePars exists in FoxTWS.jar (generated from wsimport) in ThirdParty, ext and JavaTasks directory on the server and still it complains for the same.
I tried running the same class from the command prompt on the same server and it's working fine. Thinking this could be classpath issue, I tried updating the classpath (System.setProperty("java.class.path","<jar file path>+<existing classpath>")) from with in the adapter class file and it still does not help.
Any thoughts on how to resolve this ??
Thanks in Advance.You can use below policy for 2-way SSL
Wssp1.2-Https-ClientCertReq.xml
Two way SSL. The recipient checks for the initiator's public certificate. Note that the client certificate can be used for authentication.
http://docs.oracle.com/cd/E14571_01/web.1111/e13713/message.htm#i243732
Please follow below link to invoke standalone client using SSLSocketFactory for 2-way SSL
http://docs.oracle.com/cd/E14571_01/web.1111/e13713/transport.htm#CIHICEHH
HTH
Regards,
Sunil -
Hi all,
I've just downloaded jdk1.2.2,and installed it in E:\.I've written a simple program x.java and stored it in E:\.Iam working on Windows NT 4.0(SP 5) machine.
I've set the path as E:\jdk1.2.2\bin
and classpath as
.;e:\jdk1.2.2\jre\lib\rt.jar;e:\jdk1.2.2\lib\tools.jar.
Now i opened dos prompt and iam in c:\,,and when i print javac x.java and press enter i get the error:\can't read x.java.But when change from c:\ to e:\ i can compile and run.But this is not what i want,i want to compile my program from any directory i wish,like c:\ , D:\.., i think this is a classpath problem.Could any one please help me regarding this..Thank u Very Much in advance and i really appreciate u'r response.
Sony,,Hi,
Since u r keeping u'r source file in E drive, its obvious that u must compile it from the E drive. The OS cann't search for source files from different drives, without mentioning explicitly.
U can compile by giving a command like
javac E:\x.java
I guess u want to run u'r java program from any drive... for that u need to compile the src file (.java) and put the class file anywhere and include the path of the class file in the classpath. Once u included in the classpath u can run the program from any drive..
Hope it helps
Saran -
How to access files outside a .jar file netbeans project
Hi, i need to access a file outside a built project inside netbeans. Ideally i would like this file next to the .jar file as myapp.properties. If possible i would like it so that when i am compiling and running the project in netbeans the file can be with the class files or something along those likes. Either way it would be nice to have different code for built projects and just running them outside a jar.
Heres what i got so far
properties = new Properties();
InputStream in = this.getClass().getResourceAsStream("applications.properties");
properties.load(in);
in.close();this only works if the file is next to the classes. (think thats called the classpath ? )
Thanks for any replies!!Your wrong code:
properties = new Properties();
InputStream in
= this.getClass().getResourceAsStream("applications.properties");
properties.load(in);
in.close();A right code:
// basic assumption 1: applications.properties
// is a pure ISO 8859-1 text file
// basic assumption 2: the file applications.properties
// is stored in the same directory where your
// jar file is stored
properties = new Properties();
try{
FileInputStream in // assume current dir
= new FileInputStream("applications.properties");
properties.load(in);
in.close();
catch (Exception e){
e.printStackTrace();
} -
Rookie trying to make my own package
Reading in a real good book - "Thinking in Java" by Bruce Eckel. Really helping me to understand better a lot of the stuff that I had in my Java course at school.
Got to a section where he's showing how to make your own packages. I'll lift directly:
Consider, for
example, creating an alias for System.out.println(�) to reduce
typing. This can be part of a package called tools:
//P.java
// The P.rint & P.rintln shorthand.
package com.bruceeckel.tools;
public class P {
public static void rint(String s) {
System.out.print(s);
public static void rintln(String s) {
System.out.println(s);
You can use this shorthand to print a
String either with a newline (P.rintln(�)) or without a
newline (P.rint(�)).
So, I cut and pasted right into the text editor I use to practice with, saved and compiled it in a subdirectory off of one of the directories in the CLASSPATH, followed with a little test program:
//ToolTest.java
import com.bruceeckel.tools.*;
public class ToolTest {
public static void main(String[] args) {
P.rintln("Available from now on!");
P.rintln("" + 100); // Force it to be a String
P.rintln("" + 100L);
P.rintln("" + 3.14159);
Here's the result of the compile:
C:\Thinking in Java\com\bruceeckel\tools>javac ToolTest.java
ToolTest.java:3: Package com.bruceeckel.tools not found in import.
import com.bruceeckel.tools.*;
^
1 error
C:\Thinking in Java\com\bruceeckel\tools>
At first I tried doing it on my own, making up my own package name, creating my own little source files, but got the same error. So I cut and pasted directly from the book, thinking surely it would work if I used Eckel's own code. Nope.
Any clue what's going wrong? I've checked the CLASSPATH carefully, it includes
C:\Thinki~1
Thanks
FelechaYour classpath should include "C:\Thinking in Java", not C:\Thinki~1.
Also, your ToolTest.java should be in some other folder than "C:\Thinking in Java\com\bruceeckel\tools" - javac may act weird when it can find the to-be-imported classes in both the current folder and the classpath.
If ToolTest.java had been in the folder "C:\Thinking in Java" you wouldn't have needed to modify the classpath. -
ConnectionPooling problem...
Hello,
I am having a problem with my database driver. The thing is that the class is compiling correctly, but only when I execute the createPool() function from one of my JSP's, do I get the following 500 Servlet Exception (the ConnectionPool class follows the error):
java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:120)
at ConnectionPool.createPool(ConnectionPool.java:165)
at jsp.www__isbops__com._80_0._index__jsp._jspService(//inc1.jsp:14)
at com.caucho.jsp.JavaPage.service(JavaPage.java:89)
at com.caucho.jsp.JavaPage.subservice(JavaPage.java:83)
at com.caucho.jsp.Page.service(Page.java:409)
at com.caucho.server.http.Invocation.service(Invocation.java:266)
at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:349)
at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:265)
at com.caucho.server.TcpConnection.run(TcpConnection.java:142)
at java.lang.Thread.run(Thread.java:484)
ConnectionPool.java:
Here is the connection pool class, which compiles correctly, so I don't think it is a classpath problem. Though I do correctly point to the jar file that contains the driver, and I don't "import" the driver. I have no idea what's wrong:
import java.sql.*;
import java.util.*;
public class ConnectionPool
private String jdbcConnection = "<hidden for the java forum>";
private String dbUsername = "<hidden>";
private String dbPassword = "<hidden>";
private String testTable = "testConnectionPool";
private int initialConnections = 10;
private int incrementalConnections = 5;
private int maxConnections = 50;
private Vector connections = null;
public ConnectionPool() {}
public int getInitialConnections()
return initialConnections;
public void setInitialConnections(int initialConnections)
this.initialConnections = initialConnections;
public int getIncrementalConnections()
return incrementalConnections;
public void setIncrementalConnections(
int incrementalConnections)
this.incrementalConnections = incrementalConnections;
public int getMaxConnections()
return maxConnections;
public void setMaxConnections(int maxConnections)
this.maxConnections = maxConnections;
public String getTestTable()
return testTable;
public void setTestTable(String testTable)
this.testTable = testTable;
public synchronized void createPool() throws Exception
if (connections != null)
return;
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
connections = new Vector();
createConnections(initialConnections);
public boolean isPooled() throws Exception {
if(connections == null) {
return false;
return true;
private void createConnections(int numConnections) throws
SQLException
for (int x=0; x < numConnections; x++)
if (maxConnections > 0 &&
connections.size() >= maxConnections)
break;
//add a new PooledConnection object to connections vector
connections.addElement(new PooledConnection(
newConnection()));
System.out.println("Database connection created...");
private Connection newConnection() throws SQLException
//create a new database connection
Connection conn = DriverManager.getConnection(jdbcConnection,
dbUsername, dbPassword);
if (connections.size() == 0)
DatabaseMetaData metaData = conn.getMetaData();
int driverMaxConnections = metaData.getMaxConnections();
if (driverMaxConnections > 0 &&
maxConnections > driverMaxConnections)
maxConnections = driverMaxConnections;
return conn;
public synchronized Connection getConnection() throws
SQLException
if (connections == null)
return null;
Connection conn = getFreeConnection();
while (conn == null)
wait(250);
conn = getFreeConnection();
return conn;
private Connection getFreeConnection() throws SQLException
Connection conn = findFreeConnection();
if (conn == null)
createConnections(incrementalConnections);
conn = findFreeConnection();
if (conn == null)
return null;
return conn;
private Connection findFreeConnection() throws SQLException
Connection conn = null;
PooledConnection pConn = null;
Enumeration enum = connections.elements();
while (enum.hasMoreElements())
pConn = (PooledConnection)enum.nextElement();
if (!pConn.isBusy())
conn = pConn.getConnection();
pConn.setBusy(true); //set connection to busy
if (!testConnection(conn))
conn = newConnection();
pConn.setConnection(conn);
break;
return conn;
private boolean testConnection(Connection conn)
try
if (testTable.equals(""))
conn.setAutoCommit(true);
else
Statement stmt = conn.createStatement();
stmt.execute("select count(*) from " + testTable);
catch (SQLException e)
//connection is no longer valid, attempt to close it
closeConnection(conn);
return false;
return true;
public void returnConnection(Connection conn)
if (connections == null)
return;
PooledConnection pConn = null;
Enumeration enum = connections.elements();
while (enum.hasMoreElements())
pConn = (PooledConnection)enum.nextElement();
if (conn == pConn.getConnection())
pConn.setBusy(false);
break;
public synchronized void refreshConnections() throws
SQLException
if (connections == null)
return;
PooledConnection pConn = null;
Enumeration enum = connections.elements();
while (enum.hasMoreElements())
pConn = (PooledConnection)enum.nextElement();
if (!pConn.isBusy())
wait(10000); //wait 5 seconds
closeConnection(pConn.getConnection());
pConn.setConnection(newConnection());
pConn.setBusy(false);
public synchronized void closeConnections() throws SQLException
if (connections == null)
return;
PooledConnection pConn = null;
Enumeration enum = connections.elements();
while (enum.hasMoreElements())
pConn = (PooledConnection)enum.nextElement();
if (!pConn.isBusy())
wait(5000);
closeConnection(pConn.getConnection());
connections.removeElement(pConn);
connections = null;
private void closeConnection(Connection conn)
try
conn.close();
catch (SQLException e)
private void wait(int mSeconds)
try
Thread.sleep(mSeconds);
catch (InterruptedException e)
class PooledConnection
Connection connection = null;
boolean busy = false;
public PooledConnection(Connection connection)
this.connection = connection;
public Connection getConnection()
return connection;
public void setConnection(Connection connection)
this.connection = connection;
public boolean isBusy()
return busy;
public void setBusy(boolean busy)
this.busy = busy;
}Hi,
The problem lies in the classpath. You should set the classpath of the webserver so as include the the jar file of the driver class which you are using.
If you still have any doubt, you can unzip all the classes that are present in the jar file to the directory where you place servlet class files.
Bye. -
Installation problems.... cs1\Keyboard
I installed java SKD standard ediction v1.3 in my home computer. Everything seemed to be right, until I was trying to run my program. I run it and appeared on the screen the following:
Exception in thread "main" java.lang.NoClassDefFoundError: cs1\Keyboard
I was investigating what was the problem so I think is with the classpath that does to appeared in c:\set in windows.... so i don't know how to create a classpath or what do you think I should I do?
I appreciate your help.Actually, there is a cs1 Keyboard class, but it does not come with the Java SDK. You must install it yourself. For more information about this class and how you can install it, please use this link:
http://duke.csc.villanova.edu/jss/keyboard.html -
Jar don't run - NoClassDefFoundError
Hi,
my application is running. But when I run the jar file I get this error:
Exception occurred during event dispatching:
java.lang.NoClassDefFoundError: javax/xml/transform/TransformerFactory
at de.cas.mercatorintegration.MappingTransform.mappingTransform(MappingTransform.java:66)
I think this is a classpath problem but I don't know how to solve.
I want that the needed jars like e.g. xml-apis.jar are also in the jar-file so I can deliver it as a whole to the customer.
All data files are in the directory 'de/cas/mi'
The libs are in the directory 'lib'
The manifest file looks like this:
Main-Class: de.cas.mi.Main
Class-Path: lib.js.jar lib.bsf.jar lib.xml-apis.jar lib.xercesImpl.jar lib.xmlParserAPIs.jar lib/xalan.jar lib/xerces.jar
The first part of the application works and the user interface starts. But when the first time a jar from the lib-directory is used then the error occurs.
I used this command:
java -jar Jarfilename.jar
Has somebody an idea to solve the problem?
Thanks
Frankroll back. found the solution in this news group : forum=22&thread=161143
danke
franke -
Problem calling ejb in oas from non-oracle java client
I am trying to call an ejb that is deployed in OAS 9i from a java server page running another non-Oracle app server.
I continue to get the following error:
java.lang.ExceptionInInitializerError: org.omg.CORBA.INITIALIZE: can't
instantiate default ORB implementation com.visigenic.vbroker.orb.ORB minor
code: 0 completed: No
I don't think it's a classpath problem. In desperation, I added every jar file in the Oracle directory structure to my classpath.
The ejb works fine with jsp on OAS, but (at the moment) using OAS as our production web container is not an option.
Is this even possible?
nullHi Andrei,
is that all you get? No more nested exceptions? This snippet isn't really explaining thery much...
Best regards
Stefan -
Error Report when calling Java thru C
Currently we have encountered some issues with our C code calling java module in NT- Itanium 64bit machine. We get the following error message (we don't get this on the 32 bit):
Another exception has been detected while we were handling last error.
Dumping information about last error:
ERROR REPORT FILE = (N/A)
PC = 0x0000000077f69684
SIGNAL = -1073741819
FUNCTION NAME = (N/A)
OFFSET = 0xFFFFFFFF
LIBRARY NAME = (N/A)
Please check ERROR REPORT FILE for further information, if there is any.
Good bye.
Has anybody seen this and has any suggestions? using JDK 1.4
ThanksI was thinking JVM should the classpath when it is invoked. But obviously it is not and we need to assign the classpath ourselves when invoking from native side. Thanks for pointing that out. For other people's benefit the following is the code piece I for initializing JVM.
char* str1;
char* str2;
char* classpath;
str1 = "-Djava.class.path=";
str2 = std::getenv("CLASSPATH");
classpath = (char*)malloc(strlen(str1) + strlen(str2) + 1);
strcpy(classpath, str1);
strcat(classpath, str2);
if (str2 == NULL) {
printf("CLASSPATH environment variable is not defined.");
exit(1);
m_VmArgs.version = JNI_VERSION_1_4;
m_options[0].optionString= classpath;
m_VmArgs.options = m_options;
m_VmArgs.nOptions = 1;
m_VmArgs.ignoreUnrecognized = JNI_TRUE;
JNI_GetDefaultJavaVMInitArgs(&m_VmArgs);
/* Create the Java VM */
m_Res = JNI_CreateJavaVM(&m_Jvm, (void**)&m_Env, &m_VmArgs);
if (m_Res < 0) {
printf("Can't create JVM\n");
exit(1);
thanks,
chancellor -
Error when creating a library session
Hello,
I've got an error when i try to do an ifs session:
CleartextCredential credentials = new CleartextCredential("scott", "tiger");
ConnectOptions connectOpts = new ConnectOptions();
connectOpts.setLocale(Locale.getDefault());
connectOpts.setServiceName(argv[0]);
connectOpts.setServicePassword("alicante");
LibrarySession ifs = ifsService.connect(credentials,connectOpts);
i recieve :
oracle.ifs.common.IfsException: IFS-20010: Failed to get
PropertiesResourceBundler IfsDefault
I think that's my classpath but i don't know how to change it so that the properties
which are in the oracle.ifs11.settings.oracle.ifs.server will be known.
Can you help me?
Thanks for replying me.
Regards.You need IfsDefault.properties in your CLASSPATH, but you also need LOTS of other things in your CLASSPATH as well.
Here is my classpath, you will need to modify it to suit your environment.
Also, have a look for the IFSENV.BAT file if you are running Windows. It may help you. There are other answers to your question in this dicsussion forum.
c:\jdk1.1.8\lib\classes.zip;C:\Program Files\Oracle\JDeveloper 3.2\myclasses;C:\Program Files\Oracle\JDeveloper 3.2\lib\jdev-rt.zip;C:\Program Files\Oracle\JDeveloper 3.2\jdbc\lib\oracle8.1.7\classes12.zip;C:\Program Files\Oracle\JDeveloper 3.2\lib\connectionmanager.zip;C:\Program Files\Oracle\JDeveloper 3.2\ifs\lib\adk.jar;C:\Program Files\Oracle\JDeveloper 3.2\ifs\lib\email.jar;C:\Program Files\Oracle\JDeveloper 3.2\java1.2\jre\lib\rt.jar;f:\oracle\ora81\ifs1.1\settings\oracle\ifs\server\properties;f:\oracle\ora81\ifs1.1\custom_classes;f:\Oracle\ora81\jlib\oracle8.1.6\classes111.zip;f:\ora cle\ora81\ifs1.1\lib\xmlparserv2.jar;f:\oracle\ora81\ifs1.1\lib\release.jar;f:\oracle\ora81\ifs1.1\lib\repos.jar;f:\oracle\ora81\ifs1.1\lib\tools.jar;f:\oracle\ora81\ifs1.1\lib\uti ls.jar;f:\oracle\ora81\ifs1.1\lib\adk.jar;f:\oracle\ora81\ifs1.1\jws\lib\servlet.jar;f:\oracle\ora81\ifs1.1\settings;f:\Oracle\ora81\Lib\vbjorb.jar -
Bugs in jdoc and jdoclet Ant tasks?
(The relevant lines in the build.xml file are at the end of this message.)
I encountered a problem with the jdoc Ant task:
- I added a description for a class in the metadata file. Everything rans
fine. Then I added another class to the metadata file, when the jdoc task
is invoked again by Ant the new class is not enhanced at all.
- However when I run the jdoc on the metadata file outside Ant, the new
class is enhanced.
I can't run the jdoclet task at all because Ant complains that it can't
find the class com.solarmetric.modules.integration.ant.KodoDocletTask.
However it doesn't have any problem finding the class
com.solarmetric.modules.integration.ant.JDOEnhancerTask. Aren't they both
in the kodo-jdoee.jar? I also tried using the classpath element inside the
target for the jdoclet without success.
Thanks for your help.
Here is an extract of the build.xml file:
<!--Set the classpath-->
<path id="classpath">
<pathelement location="d:/books/JDO/KODO/kodo-jdoee2.3.3/lib/jdo1_0.jar"/>
<pathelement
location="d:/books/JDO/KODO/kodo-jdoee-2.3.3/lib/kodo-jdoee.jar"/>
<pathelement location="C:\java\xdoclet-1.1.2\lib\xdoclet.jar"/>
</path>
<target name="taskdefs">
<taskdef name="jdodoclet"
classname="com.solarmetric.modules.integration.ant.KodoDocletTask"/>
<!-- the above line causes an error -->
<taskdef name="jdoc"
classname="com.solarmetric.modules.integration.ant.JDOEnhancerTask"/>
<!-- no problem with the above -->
<target name="enhanceAll" depends="compile">
<jdoc>
<fileset dir="./classes/quocp">
<include name="ent.jdo" />
</fileset>
<config licenseKey="<license key removed>" />
<classpath refid="classpath"/>
</jdoc>
</target>Actually I did have a classpath issue, the xdoclet jar was not being
included properly; once I got it included I now get this error:
BUILD FAILED: java.lang.LinkageError: duplicate class definition:
org/apache/log4j/Category
I think the xdoclet is incompatible with the version of log4j I have....but
I don't know for certain.
So I tried moving to the latest and greatest xdoclet and now I get a new
error (and it fails earlier):
Finding class com.solarmetric.modules.integration.ant.JDODocletSubTask
Exception reading component C:\dev2\java\devlib\kodo-jdo.jar
BUILD FAILED: java.lang.NoClassDefFoundError:
com/solarmetric/modules/integration/ant/JDODocletSubTask
One thing I have learned today is the -debug flag when running ant...very
helpful in finding out where the failure is occuring.
Any ideas you might have on how to proceed would be helpful...is there a way
to run the xdoclet stuff without the ant tasks?
Thanks,
Steven Balthazor
"Marc Prud'hommeaux" <[email protected]> wrote in message
news:[email protected]...
Steven-
If you include the Kodo devel jars in your system CLASSPATH, does it
work? I.e., is it a problem with the classpath, or with the XDoclet
integration in general?
In article <[email protected]>, Steven Balthazor wrote:
I have followed these instructions to the letter; but I am unable to get
the
Doclet task to work in ant. Specifically my taskdef:
<taskdef name="jdodoclet"
classname="com.solarmetric.modules.integration.ant.KodoDocletTask">
<classpath refid="cp" />
</taskdef>
Generates the following error when running ant:
BUILD FAILED: file:C:/dev2/java/devbuild.xml:54: taskdef class
com.solarmetric.modules.integration.ant.KodoDocletTask cannot be found
Now I would think this is a classpath problem; except if I change the
taskdef to:
<taskdef name="jdodoclet"
classname="com.solarmetric.modules.integration.ant.SchemaToolTask">
<classpath refid="cp" />
</taskdef>
I get a new error:
BUILD FAILED: file:C:/dev2/java/devbuild.xml:56: The <jdodoclet> task
doesn't support the nested "jdotags" element.
This looks like it is finding the SchemaToolTask and failing in the
implementation of jdodoclet. As far as I can tell, KodoDocletTask and
SchemaToolTask are in the same jar. So what gives?
I am using Kodo 2.5.2; and I have Xdoclet 1.1.2 in my classpath.
Any help would be appreciated.
Steven Balthazor
"Patrick Linskey" <[email protected]> wrote in message
news:[email protected]...
I'm guessing that the kodo jars are not in the classpath when you
launch
ant. If this is the case, then you must specify a classpath in your
taskdef, and probably in the jdodoclet execution as well. You can do
this with something like this:
<target ...>
<taskdef ...>
<classpath refid="cp"/>
</taskdef>
<jdodoclet ...>
<classpath refid="cp"/>
</jdodoclet>
</target>
This assumes that you've defined a path somewhere in your ant buildfile
with an id of 'cp'.
-Patrick
Quoc Pham wrote:
Hi Patrick,
I still haven\'t been able to solve the problem with the jdoclet
task:
>>>>
>>>>
I can\\\'t run the jdoclet task at all because Ant complains thatit
>>>>
can\\\'t
find the class
com.solarmetric.modules.integration.ant.KodoDocletTask.
However it doesn\\\'t have any problem finding the class
com.solarmetric.modules.integration.ant.JDOEnhancerTask. Aren\\\'tthey
both
in the kodo-jdoee.jar? I also tried using the classpath element
inside
the
target for the jdoclet without success.
Here is the jdoclet task:
classname=\\\"com.solarmetric.modules.integration.ant.KodoDocletTask\\\"/>
>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
When I run the above task, I got the error message:
Buildfile: build.xml
generateJdoMetadata
BUILD FAILED
file:d/jdev903/jdev/mywork/JDO/Ent/build.xml:102:taskdef class
com.solarmetric.modules.integration.ant.KodoDocletTask cannot be
found
>>>>
>>>>
Questions:
- How do I let ant know the class path to use to run this task?
- What should the value of sourcepath be?
- What should the value of dir be? The directory where the .javafiles
reside?--
Patrick Linskey [email protected]
SolarMetric Inc. http://www.solarmetric.com
Marc Prud'hommeaux [email protected]
SolarMetric Inc. http://www.solarmetric.com -
ClassDefNotFound error when calling Java from C++
Hi all,
I have a problem with calling my java from C++ through JNI.
I have set my CLASSPATH environment varible that include path to every libary that I need. My source is as follows:
#include <jni.h>
#include <stdio.h>
int main()
JNIEnv *env;
JavaVM *jvm;
JavaVMInitArgs vm_args;
jint res;
jclass cls;
jmethodID mid;
IMPORTANT: specify vm_args version # if you use JDK 1.1.2 and beyond
vm_args.version = JNI_VERSION_1_4;
vm_args.ignoreUnrecognized = JNI_TRUE;
JNI_GetDefaultJavaVMInitArgs(&vm_args);
/* Create the Java VM */
res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
if (res < 0) {
printf("Can't create JVM\n");
return 1;
cls = (env)->FindClass ("dds/test/comm/listeners/NACKListenerFrame");
if (cls == 0) {
printf("Can't find NACKListenerFrame Class\n");
return 1;
mid = (env)->GetStaticMethodID(cls, "start", "()V");
if (mid == 0) {
printf("Can't find NackListnerFrame.start \n");
return 1;
(env)->CallStaticVoidMethod((_jclass*)cls, (_jmethodID*)mid, NULL);
jthrowable e = (env)->ExceptionOccurred();
if (e) {
env->ExceptionDescribe();
env->ExceptionClear();
if ((jvm)->DestroyJavaVM() < 0) {
printf("Cannot destroy JVM./n");
return 0;
I deliberately left out the codebelow because I want the JVM I created to load Classes from the system's CLASSPATH variable as I have set path to every classes that I need, in that CLASSPATH variable.
JavaVMOption options[1];
options[0].optionString=
"-Djava.class.path=.;E:/DDSproject/DDSImplementation/classes";
vm_args.options = options;
vm_args.nOptions = 1;
But it seems like unless I specify CLASSPATH in my C++ source code the JVM could not find any classes.
I tried to put the "jvm.dll" path to the first one in the System's PATH variable. It does not work either...
Gurus Pls help!!!.. I don't know what to do... I don't wanna code my CLASSPATH in my c++ source code as above.
Thanks in advance,
chancellorI was thinking JVM should the classpath when it is invoked. But obviously it is not and we need to assign the classpath ourselves when invoking from native side. Thanks for pointing that out. For other people's benefit the following is the code piece I for initializing JVM.
char* str1;
char* str2;
char* classpath;
str1 = "-Djava.class.path=";
str2 = std::getenv("CLASSPATH");
classpath = (char*)malloc(strlen(str1) + strlen(str2) + 1);
strcpy(classpath, str1);
strcat(classpath, str2);
if (str2 == NULL) {
printf("CLASSPATH environment variable is not defined.");
exit(1);
m_VmArgs.version = JNI_VERSION_1_4;
m_options[0].optionString= classpath;
m_VmArgs.options = m_options;
m_VmArgs.nOptions = 1;
m_VmArgs.ignoreUnrecognized = JNI_TRUE;
JNI_GetDefaultJavaVMInitArgs(&m_VmArgs);
/* Create the Java VM */
m_Res = JNI_CreateJavaVM(&m_Jvm, (void**)&m_Env, &m_VmArgs);
if (m_Res < 0) {
printf("Can't create JVM\n");
exit(1);
thanks,
chancellor
Maybe you are looking for
-
Trying to set the contents of a Text View in Objective-C
Hi there, I have a properly linked up Text View (within a Scroll View) in Interface Builder, and I wish to change the value of that Text View at runtime. I am trying this code here, but it (and other similarities of it) is not working; [textField set
-
I have a Canon GL1 camera that records in SD 4:3 format. When I make a DVD my DVD player coupled with my 16:9 HDTV stretches the video to fill the screen and distorts everyone (they look broader). I think a letterbox format would present a more norma
-
Hi! Is there anyone else who has already developed application to Ranger 3D (used Ranger Toolkit for Labview?) +++ In God we believe, in Trance we Trust +++ [Hungary] Solved! Go to Solution.
-
What world traveler adapter do you use when traveling in India?
What work traveler adapter do you use when traveling in India?
-
Reducing AI size for clip art (wmf or emf) CS3 on Windows
Hello All - I was actually in an Adobe workshop last week with an Adobe goddess and she was not able to answer this question - so unfortunately, I do not have much hope. But the last question I asked on this forum was answered so quickly and accurate