aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes how to compile using Eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "how to compile using Eclipse" Watch "how to compile using Eclipse" New topic
Author

how to compile using Eclipse

Kishore Dandu
Ranch Hand

Joined: Jul 10, 2001
Posts: 1934
I have a new project and have couple of source files in there.

How can I compile these files, I can see onlt 'Run' in there.


Kishore
SCJP, blog
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
The Project menu contains the build actions (which are in part compile actions). What you need is Build Project.

However if you try Run the project will be build.

./pope


blog - InfoQ.com
Kishore Dandu
Ranch Hand

Joined: Jul 10, 2001
Posts: 1934
I am having problems with getting source set properly.

When I try to run a class with main(by clicking run on the file) it is not able to find main.

How do we set the source path correctly if the java files are sitting in a different directory from the project location itself??? It was very intuitive in JBuilder(may be because I am used to it)
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
I hope you have a good reason to organize the project this way ;-).
The solution would be:
New -> Folder -> Advanced -> Linked to folder in the file system.
Than Properties -> Java Build Path -> Source -> Add Folder (the folder from the previous step).

./pope
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
Hmmm... another solution would be to create another project containing the sources directory structure and to make the current project depend on this new defined one.

./pope
Kishore Dandu
Ranch Hand

Joined: Jul 10, 2001
Posts: 1934
I am able figure out some of the compilation issues(that are due to setup of different project properties).

One last question: for log4j to work, I need to expose of folder(where appender xml files reside) to the project. How can I do that???
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
I think you can use the -Dlog4j.configuration in run configuration.
Another solution would be to place the log4j.xml file in your build directory.

./pope
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
Originally posted by Kishore Dandu:
I have a new project and have couple of source files in there.

How can I compile these files, I can see onlt 'Run' in there.


By default of eclipse, it's auto-recompile source code when source code is changed.

But you want to manaual compile, you can do like this ::

- Cleck right at project/source in package explorer and select build project.

or

- Select Project --> Build


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
Originally posted by Kishore Dandu:
I am able figure out some of the compilation issues(that are due to setup of different project properties).

One last question: for log4j to work, I need to expose of folder(where appender xml files reside) to the project. How can I do that???


Set up Log4j in project.

1. create and put log4j.properties in your output class directory of your project.

Example to config log4j.properties



In source code




Reference Website
http://logging.apache.org/log4j/docs/
Kishore Dandu
Ranch Hand

Joined: Jul 10, 2001
Posts: 1934
may be I am not communicating correctly.

I am sure how to setup log4j(its xml files) and how to invoke it programatically.

But for a project that has log4j invokation in a java file, it needs to know the location of appender files(xml files).

Simply put, my question is "how do u add a directory to classpath in Eclipse"???
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Instead of maneuvering your mouse towards the project menu, I'd suggest learning the shortcut for building your project, CTRL-B. You'll get addicted to it, I promise...


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Kishore Dandu:
Simply put, my question is "how do u add a directory to classpath in Eclipse"???

Right-click your project and select Properties > Java Build Path > Libraries > Add Class Folder.
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
Originally posted by Lasse Koskela:
[...]learning the shortcut for building your project, CTRL-B. You'll get addicted to it, I promise...


Lol Lasse. I use emacs style shortcuts (almost all defined by myself starting with 3.0M7)... and yes, on some projects I am addicted to CTRL-B CTRL-P ;-).

./pope
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
Originally posted by Lasse Koskela:

Right-click your project and select Properties > Java Build Path > Libraries > Add Class Folder.


I would say that using -D option on Run configuration will save some time put on editing log4j.xml (I currently use 5 different log4j configurations when testing - different logging options).

./pope
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to compile using Eclipse