• 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

classpath and javac from command line

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm on a Windows system. C:\ is my root. I created the following directory structure: c:\myProject, c:\myProject\source\com\wickedlysmart, c:\myProject\classes. A pojo file named MyClass.java is in the c:\myProject\source\com\wickedlysmart folder. I'm executing the following from the command prompt (I'm currently at the myProject folder): C:\myProject> javac -classpath c:\myProject\source\com\wickedlysmart MyClass.java

This gives me "cannot read: MyClass.java" error. I thought I was telling javac to look in the absolute path "c:\myProject\source\com\wickedlysmart" for this source file. Where did this greenhorn go wrong? Thanks...
 
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Compiling from the command line can using packages and such can take some geting used to. Since it looks like your MyClass.java file is a stand-alone file (i.e. it doesnt reference any classes not currently on the classpath) you actually don't need to specify any classpath. You do however have to specify the path relative to the current directory. And if you want the .class files generated in the classes folder you use the -d option. Try;

javac -d classes source\com\wickedlysmart\MyClass.java
[ September 01, 2006: Message edited by: Garrett Rowe ]
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dude,

Nothing is more frustrating than classpath and compile issues with the JDK. But it's an important learning experience, and we've all been through it.

I think your classpath folder is just too deep. Cut it down to before the package.

I have a few tutorials on using javac and java utilities, inlcuidng one on how to use packages, both in code and with the javac and java utilites. It may be exactly what you need.

http://www.technicalfacilitation.com/examscam/get.php?link=../scja/tutorials

Cheers!

-Cameron
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dave, welcome aboard!

See if THIS helps. The Sun pages linked from the top of that one are good, too.
[ September 01, 2006: Message edited by: Stan James ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic