• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Selecting a properties file in command line

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)

 
Ranch Hand
Posts: 430
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Too difficult a question for "beginning" Moving thread.
 
G Meyer
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 430
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
pay attention...
you didn't remove -classpath!!!
 
G Meyer
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:\>
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 430
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic