Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Compiling and running

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a problem with compilation .

I have two classes in different packages : packagea and packageb .

package packegea;
public class ClassA {

}

package packageb;
import packagea.ClassA;

public class ClassB {

public static void main(String[] args) {
ClassA a ;
System.out.println("Got it");
}
}


when I try to compile ClassB from parent directoy of both folders packagea and packageb : javac packageb/ClassB
I have this error :
packageb\ClassB.java:2: error: package packagea does not exist
import packagea.ClassA;
              ^
packageb\ClassB.java:7: error: cannot find symbol
               ClassA a ;
               ^
 symbol:   class ClassA
 location: class ClassB


Please help,
thanks
 
Saloon Keeper
Posts: 12419
269
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch!

You have a typo in the package declaration in ClassA.
 
Marshal
Posts: 70625
288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome again

Compiling from the command line becomes more difficult when you use package names. One way to do it:-On Windows® use \ and on other operating systems change all \s to /. In line 6 note the . rather than \ or /
You will of course have to correct the spelling which Stephan noticed.
 
Life just hasn't been the same since the volcano erupted and now the air is full of tiny ads.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic