• Post Reply Bookmark Topic Watch Topic
  • New Topic

Deploy app  RSS feed

 
egbai mmumene
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do i compile my java program to run outside the IDE
 
Anayonkar Shivalkar
Bartender
Posts: 1558
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
egbai mmumene wrote:How do i compile my java program to run outside the IDE

Firstly, compilation and deployment are two different things.

Secondly, what kind of program it is? Is it multiple Java files? Do you want to compile those in one shot? Do you have a complex (or non-simple) package structure? Do you need to put all your classes files in some specific directory (and maintain structure of your source files)?

And most importantly - what have you tried so far? And what problem did you face?

By the way, if you haven't tried anything yet, then you may check the documentation of javac utility (which is nothing but Java compiler).
 
Joe Areeda
Ranch Hand
Posts: 334
2
Java Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also knowing which IDE makes the answer more specific.

 
egbai mmumene
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using netbeans, want it to be done in one shot so i can distribute
 
Joe Areeda
Ranch Hand
Posts: 334
2
Java Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
egbai mmumene wrote:Using netbeans, want it to be done in one shot so i can distribute

Well with NetBeans clean an build produces a dist directory in your project directory. You need to distribute the jar and the lib directory.

I'm not sure what you mean by one shot but I think you want a single jar containing all your libraries.

Eclipse has that built in but the NetBeans folks seem to think it's too easy to violate licenses or something.

There are several tutorials on how to modify build.xml to include a single-jar target such as http://wiki.netbeans.org/PackagingADistributableJavaApp

That's not the one I use but it does look similar.
 
Anayonkar Shivalkar
Bartender
Posts: 1558
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My mistake: I totally misunderstood the question.

I thought it to be 'how to compile Java code outside IDE', however, question seems to be - 'how to create the jar so that it could be run without IDE' - am I right?

If this is the case, if you are not familiar with ant, then you may think of eclipse IDE. Unlike NetBeans, eclipse does not use any external tool (e.g. ant), and though I'm not much familiar to NetBeans, it is very easy to create jar via eclipse.

Also, generally, when I need to use multiple jars, instead of packaging those in single jar, putting all jars separately in classpath would also work. I use this approach so that I need to replace only relevant jar in case of bug fixes.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!