0

I have a program which is located in

say

$A430CLASS/com.airbus.adcsip.batch.GlobalReportBatch

$A430CLASS is the path where my class file is present.

i want to run it through shell script so i entered following command :

java -classpath $A430CLASS/com.airbus.adcsip.batch.GlobalReportBatch $A430CONF/batch.properties

$A430CONF is the path where the batch.properties file is present. GlobalReportBatch is my class file name As you can see i want to pass this batch.properties file as argument to my java program. but when i run my script it tries to replace "." in batch.props file to "/" it gives me NoClassDefFound error.

tshepang
  • 12,111
  • 21
  • 91
  • 136

1 Answers1

4

What you put after the -classpath option must be a list of directories and JAR files, separated by : (on Unix-like operating systems) or ; (on Windows).

Look at what you are passing:

-classpath $A430CLASS/com.airbus.adcsip.batch.GlobalReportBatch

Remove the slash / between $A430CLASS and your class name; replace it by a space:

-classpath $A430CLASS com.airbus.adcsip.batch.GlobalReportBatch

So the entire line becomes:

java -classpath $A430CLASS com.airbus.adcsip.batch.GlobalReportBatch $A430CONF/batch.properties
Jesper
  • 202,709
  • 46
  • 318
  • 350
  • actually $A430CLASS and com....GlobalReportBatch is related.. consider $A430CLASS as my home directory... so is your syntax right? – Dattaprasad Patil Oct 03 '12 at 13:52
  • @Datta: again you've not told us your package structure yet. – Hovercraft Full Of Eels Oct 03 '12 at 13:57
  • my class file is in $A430CLASS/com/airbus/adcsip/batch/ where my class GlobalReportBatch is located... $A430CLASS - is my variable set to some xyz path so it becomes xyz path/com/airbus/..... – Dattaprasad Patil Oct 03 '12 at 14:05
  • @Datta: but again, please tell us ***what is the package structure?*** I'm not sure how to ask this any clearer sort of way. What is on the package statement at the top of your java file? – Hovercraft Full Of Eels Oct 03 '12 at 14:05
  • @ Hovercraft : sry mate coudnt understand your query... :( – Dattaprasad Patil Oct 03 '12 at 14:09
  • @Datta: at the top of the java file, there is often a package statement. It might read `package com.airbus.adcsip.batch;` or somesuch. I'm asking you to tell us exactly what is on that line. – Hovercraft Full Of Eels Oct 03 '12 at 14:12
  • its same "package com.airbus.adcsip.batch" i hope i have answered your question... – Dattaprasad Patil Oct 03 '12 at 14:20
  • Does the directory that `$A430CLASS` points to contain your package directory hierarchy, with your class files? So, the directory should contain a subdirectory `com/airbus/adcsip/batch`, and that directory should contain your class file `GlobalReportBatch.class`. – Jesper Oct 03 '12 at 14:38
  • 1
    @DattaprasadPatil Try @Jesper answer: `java -classpath $A430CLASS com.airbus.adcsip.batch.GlobalReportBatch $A430CONF/batch.properties` It should work. – user1516873 Oct 03 '12 at 14:45
  • Still getting `NoClassDefFoundError`? For which class? Your `GlobalReportBatch` class? Then there must still be something wrong with how you specify the classpath, or the directory structure isn't there, or the class file is not in the right place. – Jesper Oct 03 '12 at 14:48
  • I have checked the class file location almost 100 times now.. everything is at right place.. even i am confused y is it happening.. – Dattaprasad Patil Oct 03 '12 at 14:50
  • What do you see when you enter the command: `echo $A430CLASS`? – Jesper Oct 03 '12 at 15:17
  • @Jesper Sorry for late reply - $A430CLASS shows "/A430_VAL/server/WEB-INF/classes".. where all the class files are located.. – Dattaprasad Patil Oct 04 '12 at 05:22