Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Cannot access file after using package  RSS feed

 
Jiunshen Tzeng
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Deepti Bhatt
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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 ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!