Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Generate a JAVAC/JAVA/JAVAW command strings
Generate a JAVAC/JAVA/JAVAW command strings [message #251209] Mon, 04 February 2008 11:22 Go to next message
Eclipse UserFriend
Originally posted by: vpetrone.sympatico.ca

Hi,

I'm new to Java and Eclipse. I've been using Eclipse (v3.3.1.1 under
Windows XP) for all aspects of my first Java development and I've found it
very intuitive to work with. However, once I've completed my development,
I'd like to be able to port the compile and run functions out of Eclipse
so that non-Eclipse users may support and execute my Code. Therefore, I
need to create JAVAC and JAVA/JAVAW command strings to perform the compile
and run functions that Eclipse is performing for me.

So, my question is: does anyone know if the Eclipse JDT provides a
facility to generate the following command strings?:

1) A JAVAC command string to compile a given Java class within a package.
2) A JAVA/JAVAW command string to execute a given Java class.

Essentially, I'd like to have Eclipse generate these command strings from
the build and run properties that it has defined for a given class.

Thanks in advance,
Vic
Re: Generate a JAVAC/JAVA/JAVAW command strings [message #251233 is a reply to message #251209] Mon, 04 February 2008 12:58 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wharley.bea.com

"Vic Petrone" <vpetrone@sympatico.ca> wrote in message
news:adeedec158ca0d3b680c118542cd3540$1@www.eclipse.org...
> Hi,
>
> I'm new to Java and Eclipse. I've been using Eclipse (v3.3.1.1 under
> Windows XP) for all aspects of my first Java development and I've found it
> very intuitive to work with. However, once I've completed my development,
> I'd like to be able to port the compile and run functions out of Eclipse
> so that non-Eclipse users may support and execute my Code. Therefore, I
> need to create JAVAC and JAVA/JAVAW command strings to perform the compile
> and run functions that Eclipse is performing for me.

You should be able to export an Ant build script, which will include
everything they need, by right-clicking the project (i.e. in Package
Explorer, etc.) and selecting Export -> Ant Build Files.
Re: Generate a JAVAC/JAVA/JAVAW command strings [message #251238 is a reply to message #251233] Mon, 04 February 2008 13:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vpetrone.sympatico.ca

Walter Harley wrote:

> You should be able to export an Ant build script, which will include
> everything they need, by right-clicking the project (i.e. in Package
> Explorer, etc.) and selecting Export -> Ant Build Files.


Thanks for your reply Walter.

I've looked into Ant. It appears to create an XML that you then feed back
into an Ant program to perform a compile. However, I'd like to generate a
plain JAVAC command string aswell as an execution (JAVA or JAVAW) command
string.

Regards,
Vic
Re: Generate a JAVAC/JAVA/JAVAW command strings [message #251242 is a reply to message #251238] Mon, 04 February 2008 15:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wharley.bea.com

"Vic Petrone" <vpetrone@sympatico.ca> wrote in message
news:4fc630a0bec6d990d73fea7bbf14afa8$1@www.eclipse.org...
> I've looked into Ant. It appears to create an XML that you then feed back
> into an Ant program to perform a compile. However, I'd like to generate a
> plain JAVAC command string aswell as an execution (JAVA or JAVAW) command
> string.

So far as I know, Eclipse does not have any functionality to produce just an
isolated javac command line for compilation.

Allow me to gently suggest that for compilation, you should learn how to
make use of ant, just as if it were part of the language. (It's pretty
simple.) Ant is the industry-standard way of managing builds in Java, sort
of like "make" is for C. If your compilation command is complicated enough
to require asking this question - i.e., if you're compiling more than a
single Java file - it's complicated enough to manage with ant rather than a
batch script. Batch scripts (command lines) have a way of very quickly
growing larger than their developer initially intended.

As for launching, there are basically two scenarios: either your application
is completely contained within one jar file, or it calls upon other jar
files. If it's the first case, the command line is simply "java -jar
[yourJar]". If you've set your options properly in Eclipse, the main entry
point will be specified in the manifest.mf file, which is contained in the
jar file, so Java will know how to find it and run it. (Of course if you
have your own command line options, they need to be added as well.) If
there are more jar files, then you either need to use a tool such as
"fatjar" to combine them together, or you need to specify the classpath,
"java -cp [classpath] -jar [yourJar]". The classpath will depend on where
those other jars are installed - if they are system or third-party jars,
rather than part of your application, the classpath may be different for
different users' installations. You can also use Ant to run your
application, as well as to compile it, but that is a less common thing to
do.
Re: Generate a JAVAC/JAVA/JAVAW command strings [message #251246 is a reply to message #251242] Mon, 04 February 2008 17:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vpetrone.sympatico.ca

Hi Walter,

Thannks for your reply! I will look into learning more about Ant when time
permits.

I did figure out how to create both a compile command string and a run
command string from reading the Java doc. They both seem to work well, so
for now that's what I will use.

Thanks again!
Vic
Re: Generate a JAVAC/JAVA/JAVAW command strings [message #251254 is a reply to message #251246] Mon, 04 February 2008 19:20 Go to previous message
Eclipse UserFriend
Originally posted by: wharley.bea.com

"Vic Petrone" <vpetrone@sympatico.ca> wrote in message
news:8e3e641c512b2e4d64fc004cbbed522e$1@www.eclipse.org...
> Hi Walter,
>
> Thannks for your reply! I will look into learning more about Ant when time
> permits.

One very easy way is to allow Eclipse to generate an Ant script for you, and
then take a look at its contents.

The basic idea, just as with "make", is that you have a structure of
dependencies and associated actions. For instance, foo.jar might depend on
some .class files with the associated action of calling the 'jar' tool, and
the .class files would depend on .java files with the associated action of
calling 'javac' with appropriate flags. The rest of the ant script is just
about setting up the correct flags, environment variables, and tool
definitions.
Previous Topic:How to attach source of JSF implementation?
Next Topic:JSF app no longer deploys class files
Goto Forum:
  


Current Time: Thu Apr 24 23:54:39 EDT 2025

Powered by FUDForum. Page generated in 0.03018 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top