• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java launcher not taking classpath specified in different directory  RSS feed

 
Sree Lekshmi
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am copying one stand alone app from server machine to local machine; Server machine- the jars and app are installed in F drive, I am moving to my D drive . But class are not loading and I am getting no class def found error.

The following steps I verified in server and made the changes, Still facing the issue

1. JARS verrified in both machine,
2.Check the classpath in ENVIRONMENT VARIABLE and i tried to set it in my local machine, Still it is not working
3. Tried to set the same with java-cp, Still not working.

Even i tried to put junk values to server machine CLASSPATH and java-cp in batch file. But Application is running there. Is there anyother way classes can be set, other than ENVIRONMENT variable and java-cp.
When I put the jars in same directory- it is working. But I dont understnad how the server is working without jars in same directory or putting junk values in classpath. Please help.

below is server setting :, I just edited it to D drive no more changes.

CLASSPATH

F:\Program Files (x86)\IBM\WebSphere MQ\Java\lib\providerutil.jar;F:\Program Files (x86)\IBM\WebSphere MQ\Java\lib\com.ibm.mqjms.jar;F:\Program Files (x86)\IBM\WebSphere MQ\Java\lib\ldap.jar;F:\Program Files (x86)\IBM\WebSphere MQ\Java\lib\jta.jar;F:\Program Files (x86)\IBM\WebSphere MQ\Java\lib\jndi.jar;F:\Program Files (x86)\IBM\WebSphere MQ\Java\lib\jms.jar;F:\Program Files (x86)\IBM\WebSphere MQ\Java\lib\connector.jar;F:\Program Files (x86)\IBM\WebSphere MQ\Java\lib\fscontext.jar;F:\Program Files (x86)\IBM\WebSphere MQ\Java\lib\com.ibm.mq.jar

BATCH file :
******************
java -cp ".;commons-io-1.0.jar;commons-logging.jar;commons-logging-api.jar;F:\Progra~1\IBM\WebSph~1\Java\lib\com.ibm.mq.jar;F:\Progra~1\IBM\WebSph~1\Java\lib\connector.jar;F:\Progra~1\IBM\WebSph~1\Java\lib\charsets.jar;log4j-1.2.8.jar;MOBFANS.jar"
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I put the jars in same directory- it is working

I don't know why the java command would look in a jar file that was not specifically specified on its classpath.
Can you show the commandline that was used for the test that "is working"?

I've had problems with Windows DOS folder names like: WebSph~1 
Have you tried replacing those names with the full name?
 
Sree Lekshmi
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes this is the command line

java -cp ".;commons-io-1.0.jar;commons-logging.jar;commons-logging-api.jar;F:\Progra~1\IBM\WebSph~1\Java\lib\com.ibm.mq.jar;F:\Progra~1\IBM\WebSph~1\Java\lib\connector.jar;F:\Progra~1\IBM\WebSph~1\Java\lib\charsets.jar;log4j-1.2.8.jar;MOBFANS.jar"

Also, i tried giving full name, but showing the same issue. One thing i noticed in working server is i gave command line as blank and CLASSPATH some junk value..but app is running..So i guess the value is setting somewhere.
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jars and app are installed in F drive, I am moving to my D drive 

Can you post the commandline for the jar files in the D: drive? 

i guess the value is setting somewhere.

What is in the environment variable: CLASSPATH?
 
Sree Lekshmi
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Command line:

java -cp ".;commons-io-1.0.jar;commons-logging.jar;commons-logging-api.jar;D:\Progra~1\IBM\WebSph~1\Java\lib\com.ibm.mq.jar;D:\Progra~1\IBM\WebSph~1\Java\lib\connector.jar;D:\Progra~1\IBM\WebSph~1\Java\lib\charsets.jar;log4j-1.2.8.jar;MOBFANS.jar"

CLASSPATH :

D:\Program Files (x86)\IBM\WebSphere MQ\Java\lib\providerutil.jar;F:\Program Files (x86)\IBM\WebSphere MQ\Java\lib\com.ibm.mqjms.jar;D:\Program Files (x86)\IBM\WebSphere MQ\Java\lib\ldap.jar;D:\Program Files (x86)\IBM\WebSphere MQ\Java\lib\jta.jar;D:\Program Files (x86)\IBM\WebSphere MQ\Java\lib\jndi.jar;F:\Program Files (x86)\IBM\WebSphere MQ\Java\lib\jms.jar;D:\Program Files (x86)\IBM\WebSphere MQ\Java\lib\connector.jar;D:\Program Files (x86)\IBM\WebSphere MQ\Java\lib\fscontext.jar;D:\Program Files (x86)\IBM\WebSphere MQ\Java\lib\com.ibm.mq.jar
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java -cp ".;commons-io-1.0.jar;commons-logging.jar;commons-logging-api.jar;D:\Progra~1\IBM\WebSph~1\Java\lib\com.ibm.mq.jar;D:\Progra~1\IBM\WebSph~1\Java\lib\connector.jar;D:\Progra~1\IBM\WebSph~1\Java\lib\charsets.jar;log4j-1.2.8.jar;MOBFANS.jar" 

The ~1 are still being used.  Try the full path.

That command line does not include the name of the starting class.

What happens when that command line is used?  Copy the contents of the command prompt window showing what happens when that line is used.
 
Sree Lekshmi
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I removed the class name before posting here since it specifies the vendor name. I added class name before executing and it shows " Could not find or load main class"
 
Sree Lekshmi
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a chance that exe got corrupted while copying...?
 
Carey Brown
Saloon Keeper
Posts: 3315
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sree Lekshmi wrote:I am getting no class def found error.
Which class is it saying is not found? Could you post the actual error message.
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It will help us if you would copy the contents of the command prompt window and paste it here.  Change anything that you want kept private but be sure to have valid syntax.

Here is the contents of a command prompt that gets the Could not find or load main class message when java could not find the class: asdas which does not exist:

Microsoft Windows [Version 10.0.10586]
(c) 2015 Microsoft Corporation. All rights reserved.

C:\Users\Norm>java asdas
Error: Could not find or load main class asdas

C:\Users\Norm>
 
Sree Lekshmi
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PFB

D:\FANS ITM>java -cp ".;commons-io-1.0.jar;commons-logging.jar;commons-logging-api.jar;com.ibm.mq.jar;connector.jar;log4j-1.2.8.jar;OCDFANS.jar" com.st.fans.FANS
Error: Could not find or load main class com.suntrust.fans.FANS
 
Sree Lekshmi
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Post Today 2:32:51 PM     Subject: Java launcher not taking classpath specified in different directory
PFB

D:\FANS ITM>java -cp ".;commons-io-1.0.jar;commons-logging.jar;commons-logging-api.jar;com.ibm.mq.jar;connector.jar;log4j-1.2.8.jar;OCDFANS.jar" com.st.fans.FANS
Error: Could not find or load main class com.st.fans.FANS
 
Carey Brown
Saloon Keeper
Posts: 3315
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sree Lekshmi wrote:D:\FANS ITM>java -cp ".;commons-io-1.0.jar;commons-logging.jar;commons-logging-api.jar;com.ibm.mq.jar;connector.jar;log4j-1.2.8.jar;OCDFANS.jar" com.st.fans.FANS
Error: Could not find or load main class com.st.fans.FANS
Which one of the jar files is supposed to contain com.st.fans.FANS ? Have you looked inside the jar file to see if it is actually there? If so, does it contain a main() method with the proper signature?
 
Sree Lekshmi
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If i run like this in command promt, java -cp ".;D:\Program Files (x86)\IBM\WebSphere MQ\Java\lib\com.ibm.mq.jar;commons-io-1.0.jar;commons-logging.jar;commons-logging-api.jar;ATMFANS.jar" com.st.fans.FANS

I am getting error- "Could not load main class com.st.fans.FANS"
If i am omiting the" D:\Program Files (x86)\IBM\WebSphere MQ\Java\lib\com.ibm.mq.jar;" this is saying MQException not found. How to incorporate both ?
 
Sree Lekshmi
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey.. I got it resolved by setting it to below

java -cp ".;D:\Program Files (x86)\IBM\WebSphere MQ\Java\lib\com.ibm.mq.jar;commons-io-1.0.jar;commons-logging.jar;commons-logging-api.jar;OCDFANS.jar" com.st.fans.FANS

So it is working fine in command prompt..but while running the application , I am still seeing the "No class found exception" Do I need to recreate the exe?
 
Paul Clapham
Sheriff
Posts: 22828
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's this "exe" you are talking about?
 
Sree Lekshmi
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The classpath is set in batch file and a .exe file is created based on the batch. So for running the application which is exposed as service, this .exe file is executing..
Since i changed the batch file, do i need to recreate this .exe, because i am getting the same old "No class exception here"..but through command prompt java-cp is reading.
 
Paul Clapham
Sheriff
Posts: 22828
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have no idea how you tell this "exe" thing what classpath to use, and nor do I have any idea how it deals with that. Should I assume you're running the "exe" on a different computer? I notice that your classpath (the command-line version) includes some relative paths, so perhaps that's the problem. Or perhaps it isn't. Does the documentation for whatever you are using to build the "exe" not have any information about configuring its classpath?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!