| Author |
Selecting a properties file in command line
|
G Meyer
Greenhorn
Joined: Oct 22, 2009
Posts: 4
|
|
"C:\Program Files\Java\jdk1.6.0_06\bin\javac" C:\pw\NCClient.java
java -classpath NCClient netconnect.properties
I am trying to use the above command line, in a batch file, to run NCClient with the netconnect.properties as a properties file. It is giving me the noclassdefound error. I've tried it a hundred different ways but it won't work. It compiles but then complains that it can't fine netconnect.properties.
ANy help would be appreciated. Following is the error it is giving me.
U:\>"C:\Program Files\Java\jdk1.6.0_06\bin\javac" C:\pw\NCClient.java
C:\pw\NCClient.java:8: warning: sun.misc.BASE64Encoder is Sun proprietary
d may be removed in a future release
import sun.misc.BASE64Encoder;
^
C:\pw\NCClient.java:150: warning: sun.misc.BASE64Encoder is Sun proprieta
and may be removed in a future release
BASE64Encoder base64encoder = new BASE64Encoder();
^
C:\pw\NCClient.java:150: warning: sun.misc.BASE64Encoder is Sun proprieta
and may be removed in a future release
BASE64Encoder base64encoder = new BASE64Encoder();
^
Note: C:\pw\NCClient.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
3 warnings
U:\>java -classpath NCClient c:\pw\netconnect
Exception in thread "main" java.lang.NoClassDefFoundError: c:\pw\netconne
Caused by: java.lang.ClassNotFoundException: c:\pw\netconnect
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
|
 |
Leandro Coutinho
Ranch Hand
Joined: Mar 04, 2009
Posts: 415
|
|
You are running properties class that is in the netconnect package. I think this is not what you want.
Run just: java NCClient netconnect.properties
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32830
|
|
|
Too difficult a question for "beginning" Moving thread.
|
 |
G Meyer
Greenhorn
Joined: Oct 22, 2009
Posts: 4
|
|
Thanks for the Reply, Leandro.
Running 'java NCClient netconnect.properties' gives me this error. It thinks it is looking for a class but what I'm trying to pass it is a properties file.
C:\>java -classpath NCClient netconnect.properties
Exception in thread "main" java.lang.NoClassDefFoundError: netconnect/properties
Caused by: java.lang.ClassNotFoundException: netconnect.properties
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
C:\>
Here is my main and the Properties function
|
 |
Leandro Coutinho
Ranch Hand
Joined: Mar 04, 2009
Posts: 415
|
|
pay attention...
you didn't remove -classpath!!!
|
 |
G Meyer
Greenhorn
Joined: Oct 22, 2009
Posts: 4
|
|
If I do remove -classpath, I get this error
Thanks
Exception in thread "main" java.lang.NoClassDefFoundError: NCClient
Caused by: java.lang.ClassNotFoundException: NCClient
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
C:\>
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16487
|
|
|
Okay, then put it back, but this time actually specify the classpath. You didn't have one before so the java command assumed that what came next was the classpath.
|
 |
Leandro Coutinho
Ranch Hand
Joined: Mar 04, 2009
Posts: 415
|
|
Does NCClient is inside some package? (package ...)
Are you running from the directory where has the NCClient.class file?
|
 |
G Meyer
Greenhorn
Joined: Oct 22, 2009
Posts: 4
|
|
Thanks Paul And Leandro
That was what I was doing wrong. I wasn't setting the classpath. Once I added the c:\cw it worked.
Thanks Much. This is a great site. You wre very helpful and I appreciate it.
GM
C:\>java -classpath c:\cw NCClient netconnect.properties
Properties File Initialization -- Start
Properties Initialization -- Start
Properties Initialization -- End
1
2
3
|
 |
 |
|
|
subject: Selecting a properties file in command line
|
|
|