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

Import Statement using key word  RSS feed

 
raj kothari
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some 100 java files. Let's say in many files, I have import statement like
net.sf.hibernate.abcxyz
Now, I want to use Hibernate3 for example. I will have to change all files import as
net.sf.hibernate3.abcxyz

I just want to know is it possible to make these imports from some other files, may be any text file, xml file, or application resources using some key value. So, I just change the key and all imports are automatically done.

Please do not reply saying rename the jar itself, or use eclipse->find and replace in all files. All that I know, i just want to whether java has any inbuilt solution to it.
 
Sidd Kulk
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A rather crude approach would be to form a java class in which you import all these classes, and then import that java class everywhere, so that whenever you need to change the imports, you can do it at only one place.

Sid
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A rather crude approach would be to form a java class in which you import all these classes, and then import that java class everywhere

That would not work Java imports do not work like C includes.
[ May 23, 2007: Message edited by: Satou kurinosuke ]
 
Kaydell Leavitt
Ranch Hand
Posts: 690
Eclipse IDE Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using the Refactor > Name option in Eclipse might work. Eclipse parses Java and is much smarter than plain text editors.

I'm not sure this would work in this case. Just an idea to try out.

Kaydell
 
raj kothari
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Kaydell Leavitt:
Using the Refactor > Name option in Eclipse might work. Eclipse parses Java and is much smarter than plain text editors.

I'm not sure this would work in this case. Just an idea to try out.

Kaydell


I am not interested knowing how IDE's do support this. I am also sure Eclipse, NetBeans would do the job. I want to know java's mechanism to handle this.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to know java's mechanism to handle this

You have to refactor, and using the IDE is the easiest way. There's no way you can avoid that.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!