• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

how do i compile a program in packages

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the code to a program. However the program is split up into multiple packages. If i try to compile from the command line using "javac *.java" i get a bunch of "package does not exist" errors along with a slew of "cannot resolve symbol" errors for objects that are defined within seperate packages. The imports are all there and i know it should compile, but i just don't know how to do it.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It sounds like you need to set your classpath variable so that the Java compiler knows where to look for these packages.

See the following page*...
http://faq.javaranch.com/view?HowToSetTheClasspath

For detailed information on packages and how classpath works with import statements, see the "Hiding the Implementation" chapter in Bruce Eckel's Thinking in Java...
http://www.faqs.org/docs/think_java/TIJ307.htm


* Note: In the unlikely event you are running Windows ME, then editing autoexec.bat will not work to set classpath. Instead, select Start / Programs / Accessories / System Tools / System Information. A "Microsoft Help and Support" window should appear. From the Tools menu in this window, select System Configuration Utility, then click on the Environment tab to set classpath.
[ January 18, 2005: Message edited by: marc weber ]
 
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Been awhile since I compiled from the command line , but I think you have to list the files in the argument to javac.

javac com/package/*.java com/otherpackage/*.java

and so on.

If that doesn't work, or even if it does, I would recommend looking at eclipse or intellaJ or one of the other great IDE's available. (my personal favorite is eclipse).
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

If that doesn't work, or even if it does, I would recommend looking at eclipse or intellaJ or one of the other great IDE's available. (my personal favorite is eclipse).



And that's the worst advice you could have given as it hides the fact that the user doesn't know how to compile things himself...

Find the root class of the application (so the class that calls all the others explicitly or implicitly) and compile that.
If you've not done weird things like determining what to call through reflection or deserialisation that should cause the compiler to automagically compile everything else for you.
 
Chad Olsson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I actually have been using eclipse to develop the program, and it compiles and works fantastically. I just wish i knew how eclipse built it because it looks like i'm going to need to be able to build the entire project without eclipse. Does eclipse generate a makefile or something to build the program? If so how can i see it?
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic