aspose file tools*
The moose likes Beginning Java and the fly likes packaging and class path?  weird problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "packaging and class path?  weird problem" Watch "packaging and class path?  weird problem" New topic
Author

packaging and class path? weird problem

osgaldor Storm
Greenhorn

Joined: Feb 28, 2013
Posts: 7
Hi:

I've been writing java for about a year now. I took a semester of it in college and I love it! In our class, however, we only used Netbeans and spent only a few minutes in one class period talking about compiling at the command line. I have a program I've been working on for some time, but it's kicking my butt. I have the class built and a main class to instantiate and run my class. i want my program to run at the command line, but when I go to compile it at the command line, the compile fails because it says it can't find my class that I built. It's in the same directory with the main class and I have them under the same package name.

What's weirdest about it is that when I run it in Netbeans, it's beautiful, runs exactly as it should, but it won't even compile outside of Netbeans. It's so frustrating, and I can't figure out what in the world is wrong. I've been pouring through all my java books and the closest I can get is that it may have something to do with the package and the classpath.

Can anyone help me figure out what I'm doing wrong?

Stormy
Saif Asif
Ranch Hand

Joined: Aug 11, 2011
Posts: 440

Hello osgaldor Storm ,

Can you please provide more information ?

1) What is the command you use to compile and then execute from the command line

2) what is your package hierarchy ?

3) can you share the code you are trying to compile ?


Muhammad Saif Asif Mirza
OCJA(5/6) OCJP(6) OCJWCD(6)
osgaldor Storm
Greenhorn

Joined: Feb 28, 2013
Posts: 7
I am compiling with javac age.java

i'm running with java age

The package structure is just one level package age;

Would you like me to post the code for my class or the main method class? i can give you any or all of it.

Thanks!
Saif Asif
Ranch Hand

Joined: Aug 11, 2011
Posts: 440

Just tell me are you using any external classes or just the core java classes ? By external classes I mean is your code dependant on any jars like e.g log4j.jar or junit.jar etc etc ?

Yes do share the code for the myclass and main method both
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40058
    
  28
Welcome to the Ranch
As Saif Asif says, we cannot help unless we know all about your folder structure and which directory you are trying to compile from.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: packaging and class path? weird problem