It appears you have not yet registered with our community. To register please click here...

 
Go Back [M] > Hardware Madness > Hardware/Software Problems, Bugs
Java stuff... Java stuff...
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Java stuff...
Closed Thread
 
Thread Tools
Old 21st December 2005, 10:18   #1
AngeluS
 
Posts: n/a
Default Java stuff...

HELP!!

I know it has been a very long time since I have been active here, forgive me for that. Other things in life and such stopped me from residing here alot.
To atone for this I will come here on a more regular base from now on. :-)

It's been almost 2 years now since I have programmed in Java.
Now I'm on a project were I will have to start using java again.
I also want to start using it again for my own amusement, developing small useless but funny things and stuff.
The problem is that I don't have much spare time at work or after work to search and experiment to learn what I need to know.
Plain OO programming is not the problem.
The problem is using extra things that should not be extra but mandatory.
Let me give you the three parts on which I am suffering for the moment.

- commons logging and log4j.
How exactly to use this?
I know what to write in my java files and such but where do I place properties file and what exactly needs to be in there? Anything else needed besides the properties file and the code in the java file...
Simple example of this would explain everything.

- Ant!
Brilliantly easy thing to use, I've seen it in action already on a project but I don't know how to use it myself. Anyone has a simple example for this?

- Eclipse
Looks nice to use, I can use it already but tips and pointers to better profit of this tool are always welcome.


Thanks in advance,
AngeluS
 
Old 21st December 2005, 14:30   #2
AngeluS
 
Posts: n/a
Default

I succeeded in using log4j now in the easiest way (everything in java code). So without the properties file I can do that now, however the properties file won't be a problem anymore since I understand (almost) everything of log4j from now on.

Next thing on the agenda: Ant.
I'll be doing that at the end of the week. :-)

Great forum, I come back here with problems and just writing them here helps me solve them.
 
Old 21st December 2005, 18:57   #3
[M] Reviewer/HWBot *****
 
Join Date: May 2002
Posts: 3,344
RichBa5tard Freshly Registered
Default

- log4j:
There are many ways to configure log4j. A quick yet clean way is to use a propertyfile. Simply name it log4j.properties and put it in your classpath.

An example log4j prop file:

log4j.rootCategory=INFO,A1,fileout

log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternL ayout
log4j.appender.A1.layout.ConversionPattern=%-5p %-M %c{2} - %m\n

log4j.appender.fileout=org.apache.log4j.RollingFil eAppender
log4j.appender.fileout.File=hwbot.log
log4j.appender.fileout.MaxFileSize=10000KB
log4j.appender.fileout.MaxBackupIndex=3
log4j.appender.fileout.layout=org.apache.log4j.Pat ternLayout
log4j.appender.fileout.layout.ConversionPattern=%d %-5p %t %c{2} - %m%n



A1 = console


- Ant is good, maven is better.
__________________
HTPC (mac osx): Mac Mini | Core Duo 1.6Ghz | 2GB DDR2 | 26\" TFT
Development (mac osx): Macbook | Core 2 2.0Ghz | 4GB DDR2 | 250GB HD
Games (win xp): E2160 @ 2.4Ghz | HD3850 OC | Asrock 4coredual-vsta | 2GB DDR2
RichBa5tard is offline  
Old 21st December 2005, 20:11   #4
AngeluS
 
Posts: n/a
Default

Come on RB, don't tease me.
Tell me why maven is better and better yet, provide us with an example
 
Old 21st December 2005, 21:35   #5
[M] Reviewer/HWBot *****
 
Join Date: May 2002
Posts: 3,344
RichBa5tard Freshly Registered
Default

Let's start with a history lesson:
In the beginning a developper had to compile and package his code manually, which was a very time consuming and tedious task.
Later, 'make' was used, which was in essence a bunch of bash scripts bundled in a single file with a few different targets to execute.
Ant has expanded make's capabilities with dozens of built in tasks (compile, deploy, package jar, ...) which can be chained and trigered by invoking a target, but it is still up to the developper to configure all the properties, dirs, ... and write almost the same code for each project. eg when you're building a web application, the steps taken to deploy a new build on your server will first to compile your code, than to build the webarchive structure, than to copy property files, than the class files, than the jars, ... 37steps later..., than to deploy the war on the server. While it's very usefull to have handwritten build scripts for ant, it's very timeconsuming to write, and not very easy to maintain. It's also a pain for a new developper to learn the build scripts, as each project has slightly different targets and structure.

Maven(2) takes it a step further. It recognizes 2 main problems you're confronted with ant:
- writing ant scrips takes a lot of time, while in essence it's basically the same for every project
- developpers should be able to use the ant scripts immediatly without having to study it first.

When you're using maven, you'll have to write one xml file which describes the project: the kind of project (jar, war, ear), the name, the dependencies (which jars it depends on), etc.

Each maven project has the same goals, if you want to compile your code, type 'mvn compile'. If you want to package your code in a war/jar/ear, type 'mvn package'. If you want to test, type 'mvn test'. You don't have to know anything about the project, nor do you have to tell maven how to test your code (it searches for all junit tests and executes it), or how to package a war (it knows your source files and knows how to package it), have to worry about dependencies (depended jars are automatically downloaded), etc.

One huge downside of maven2: it's new and fairly undocumented. maven1 is well documented, but it has some important flaws. : /
__________________
HTPC (mac osx): Mac Mini | Core Duo 1.6Ghz | 2GB DDR2 | 26\" TFT
Development (mac osx): Macbook | Core 2 2.0Ghz | 4GB DDR2 | 250GB HD
Games (win xp): E2160 @ 2.4Ghz | HD3850 OC | Asrock 4coredual-vsta | 2GB DDR2
RichBa5tard is offline  
Old 23rd December 2005, 09:42   #6
AngeluS
 
Posts: n/a
Default

SocketException, ok can catch that one.
Problem is when I get this exception because of a socket closed error then I need to do something else than with other socketexception errors.
How again do I do this?...
 
Old 23rd December 2005, 16:01   #7
[M] Reviewer/HWBot *****
 
Join Date: May 2002
Posts: 3,344
RichBa5tard Freshly Registered
Default

you can catch different type of exceptions for one block of code, just put the most specific one on top

eg
try {
// do sth that can throw a whole bunch of exceptions
} catch (SocketException) {
// log socket exception
} catch (IOException) {
// catch every ioexception but socket excpetion
}
__________________
HTPC (mac osx): Mac Mini | Core Duo 1.6Ghz | 2GB DDR2 | 26\" TFT
Development (mac osx): Macbook | Core 2 2.0Ghz | 4GB DDR2 | 250GB HD
Games (win xp): E2160 @ 2.4Ghz | HD3850 OC | Asrock 4coredual-vsta | 2GB DDR2
RichBa5tard is offline  
Old 24th December 2005, 01:29   #8
AngeluS
 
Posts: n/a
Default

yeah yeah i know that.
but how to catch a socket closed exception differently than a socket already in use exception.
I'm not completely noob in java, almost but not yet.
 
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Coverity Introduces Thread Analyzer for Java Shogun WebNews 1 10th May 2008 13:45
DigiSoft announces General Availability of a Java Platform Micro Edition Shogun WebNews 0 11th April 2008 19:19
SiSoftware Sandra XII (2008) Released: .NET and Java support jmke WebNews 1 20th August 2007 22:04
selling or trading loads of pc stuff kr15t0f For Sale 36 2nd October 2005 11:49
old stuff, what to do Rutar Off-Topic Hangout 8 12th June 2005 17:24
thinking of selling all my WC stuff TeuS General Madness - System Building Advice 2 27th April 2004 21:04
java problem Vicelord- Hardware/Software Problems, Bugs 2 30th October 2002 09:05

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


All times are GMT +1. The time now is 00:02.


Powered by vBulletin® - Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO