Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!

Stefan Willi

Ranch Hand
+ Follow
since Mar 11, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Stefan Willi

Hi!

I ask myself, if it is possible with maven to specify a dependency (or classpath) only for the unit tests and not for compiling the project sources.

Now, perhaps you wonder, why I need this.
Our project is splittet into serveal layers. And for each layer we have a eclipse-project and a own pom. For the unit test, we need serveral common classes (usually helpers and dummy-objects) and I won't that these classes are visible while compiling the project.

any idea?

Stefan
17 years ago
The state of the variables after the last loop in the while are:
i = 8
j = 5
Now the condition i <= j = false.
But the post ++ and -- operator increment and decrement the variables after evaluating the condition (i++ <= j--). The new values are i = 9 and j = 4

Stefan
Let me take one addition.

Don't be confused by the result of the following code

If you try to compare Strings in this manner, you have to know, that there are not two strings createt. Java uses a Literal-Pool and uses for the property first and second the same String-Object. So the references are the same and the == Operator would return TRUE.

Stefan
17 years ago
The answer of your second question:
If you use the == Operator, then you compare the references of an Object, not there value.

after " String ".trim() you got a new reference to a String Object, which contains the value "String".

To compare the value of 2 Strings, you have to use equals() or equalsIgnoreCase().

Stefna
17 years ago


Stefan
17 years ago

Originally posted by Jason Kwok:

Ok wow, that sounds like a great idea. My next question will probably seem obvious, how do I do that?



Assuming, your db-table is named myTable and the column is named myDate and your Connection Object to the DB is named con


Please note, that the method setDate() needs a java.sql.Date, not a java.util.Date. So you may need to convert your date object.

Stefan
[ April 21, 2005: Message edited by: Stefan Willi ]
17 years ago
Hi!
You should take a look at Sun's Java Tutorial.

Here is an example (from the link above) to copy a file:


Stefan
17 years ago

Originally posted by Jason Kwok:

I was going to use something like:
DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.CANADA);

But how can I get the date from this as a string which can be loaded in my saleBean, and eventually loaded into my database??



You get a String, which represent the date by



But, if you want to store a date in a database, why dont store it as date, instead of a string? If you use a PreparedStatement, you can use the setDate() method and the JDBC-driver do the rest for you.

stefan
17 years ago
You can add your jar to your classpath, then the location of your jar can be anywhere.

Stefan
17 years ago
Here are a small example:

Assuming, your jar in on classpath and include a file named "links.jpg".

Stefan
17 years ago
How do you access the files? Please, post your code!

Generally, it should be not a problem, to read files from a jar-file.

If you read the jars content via the classloader (getClass().getResource()), then you have to ensure, that the jar is on your classpath.

I know, this is maybe not a very usefull answer, but perhaps a point of starting for you.

Post your code and we can help you with your special problem.

stefan
[ April 14, 2005: Message edited by: Stefan Willi ]
17 years ago
Hi!

Yeah, the class looks fine, but remember, that you perhaps need the package declaration, if there is an package...

If you want test your code, you can simply add a static main method in your class, like the following one.


Use the following commands to compile and run your class.

javac Berth.java
java Berth



I dont know your intention by creating the display method. But, if you only want a method, which produce a String representation of your class, then override the toString() Method from the Object.class (You know, each Class in Java is extending from Object).


I like to add a further annotation!
Java loves naming conventions. EG. A getter or setter Method starts with get/is/set followed by a capitalized Letter. eg. getBerthWidth(). But this is only a recommendation.


Hope, this was usefull.

Stefan
17 years ago
hi kamesh!

Dont worry about that!

In a property-file, there are some characters with a special meaning e.g. = : ! #.

The store-method will escape these characters with a \ eg \: So the load method can interpret the property file correctly.

after re-loading the property file, the content will be right.

Stefan.
[ April 13, 2005: Message edited by: Stefan Willi ]
17 years ago
If you get an compile Error, then try



You must not use the c ut tag, you simply can use the EL.

I have not tried this code, but think, this should work.

Stefan
[ April 08, 2005: Message edited by: Stefan Willi ]
17 years ago
JSP
Hello Michael!

Yeah, a new member....

You could iterate over your collection "UB101_SHUTARU_GYOSHU" and create for each item a radio button.
Like this code:


For the code above, you need JSTL and EL.

If you like, you could youse logic:iterate instead of c:forEach.

If you like to disable the smilies in a post, use the checkbox "Disable smilies in this post" at the end of the post-formular.

Stefan
[ April 07, 2005: Message edited by: Stefan Willi ]
17 years ago