Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Selecting a properties file in command line

 
G Meyer
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Too difficult a question for "beginning" Moving thread.
 
G Meyer
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pay attention...
you didn't remove -classpath!!!
 
G Meyer
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20954
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does NCClient is inside some package? (package ...)
Are you running from the directory where has the NCClient.class file?
 
G Meyer
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic