Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Class And Package

 
Manoj G S
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to find in which Package a .class file belongs
 
Henry Wong
author
Marshal
Pie
Posts: 21385
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Manoj G S:
How to find in which Package a .class file belongs


Have you simply tried it? If you have a .class file (say A.class), and you don't know what package it is in... have you just tried "java -cp . A"? If the A.class file is not in the default package, the class loader should complain about the name being wrong. It will also give you the wrong name -- which includes the package.

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic