• 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

Cannot access file after using package

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello There,

i just wrote a java project. It could run smoothly without package but if i add the "package com.test" then it could not find the file i assigned. It is not classpath problem i think, since it could be compile successfully. Thanks for your help~!

Jiunshen
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I just answered another post about package and import and such. If you put a package statement in your code, you need to make it match the path to the file from the directory the compiler starts in. So if you start the compiler in a directory called "src" your file would have to be in a directory called "src/com/test".
 
Jiunshen Tzeng
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Stan,

Yes, I think I put the files in the right folder (C:\temp\com\test\) and compile the code at C:\temp\ However, the problem still happened.

Anyway, thanks for your prompt reply.

Jiunshen
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tzeng,

Pl. make sure that while running u are in C:\Temp directory and use
java com.test.MainClassName
[ December 06, 2004: Message edited by: Deepti Bhatt ]
 
Onion rings are vegetable donuts. Taste this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic