• Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating jar files with eclipse ?  RSS feed

 
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1 - As a somewhat experienced beginner, will I "cripple" myself by using eclipse instead of command line ?

2 - I have two projects B and C. C uses classes in B. I want to convert C to a jar, using eclipse. I want to know the different ways in which I can do this.
I know we can do it by configuring build path of C to include B, ie dependency. How do we do it without the dependency ? How do we do it with import
statements and without them ? How do we do it using the import menu in eclipse ?

3 - How do we do each of the things in 2 with command line ?

Thanks.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1:
Eclipse is an IDE. It highlights code syntax, it builds JARs, it connects to SVN, it has code completion, and it does hundreds of little other things. Using Eclipse will not cripple you, but can only help you.

2:
I've never done that before

3:
I've never done 2 before.
 
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andy Jack wrote:1 - As a somewhat experienced beginner, will I "cripple" myself by using eclipse instead of command line ?

Cirpple? No. Hamper. Yes
Using a command line will help you learn how important concepts like packages, path, classpath, difference between the two. IDEs like Eclipse will abstract all this from you. I would suggest start off with command line, and then graduating to IDEs.

Andy Jack wrote:
2 - I have two projects B and C. C uses classes in B. I want to convert C to a jar, using eclipse. I want to know the different ways in which I can do this.
I know we can do it by configuring build path of C to include B, ie dependency. How do we do it without the dependency ? How do we do it with import
statements and without them ? How do we do it using the import menu in eclipse ?

If you want to use any external class/package in your code, you need to ensure the classes/jar is available on the class path. Jar is nothing but a "zipped" version which can contain one single class or typically a package hierarchy. More on classpath here https://www.coderanch.com/how-to/java/HowToSetTheClasspath

Andy Jack wrote:
3 - How do we do each of the things in 2 with command line ?

More about jar files here http://docs.oracle.com/javase/1.4.2/docs/tooldocs/windows/jar.html
 
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andy Jack wrote:1 - As a somewhat experienced beginner, will I "cripple" myself by using eclipse instead of command line ?

It won't cripple you. just make sure you know how Java works and know about classpaths (because it will become important).

2 - I have two projects B and C. C uses classes in B. I want to convert C to a jar, using eclipse. I want to know the different ways in which I can do this.

You can add project B to project C's classpath using the Project > Properties dialog > Java Build Path on the Projects tab. Or you can export project B as a JAR and add the JAR to project C's build path (on the Libraries tab). Either way you want to go to the Order and Export tab and add project B's Project/JAR.

You can export a project to a JAR either 'manually' by right-clicking on the project, choosing Export... > Java > JAR (or Execuatble JAR). When prompted for the resources to export, make sure you include the project B Project/JAR as well.

You can add an Ant Build script to automate building the JAR using Project > Properties > Builders and adding a new Ant Builder (there will be significant configuration required).

I know we can do it by configuring build path of C to include B, ie dependency. How do we do it without the dependency ?

Copy the .java files into project C, or stop using two separate projects.
How do we do it with import statements and without them ?

Don't try avoiding import statements. The only way to avoid this is if you put everything in one package, which is bad practice.

How do we do it using the import menu in eclipse ?

My eclipse doesn't have an import menu.
 
Andy Jack
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Russell Slighton wrote:1:
Eclipse is an IDE. It highlights code syntax, it builds JARs, it connects to SVN, it has code completion, and it does hundreds of little other things. Using Eclipse will not cripple you, but can only help you.

2:
I've never done that before

3:
I've never done 2 before.


Bliss !
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!