Adrian Cordoba

Greenhorn
+ Follow
since Jul 09, 2011
Adrian likes ...
Java Linux Oracle
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 Adrian Cordoba

Thank you, for reply.
I use the same method to populate the JList from database in both cases: before and after the insertion.
I could make some debug:
I just print the order of the objects from the ResultSet I got from stored procedure: after the insertion, the added object appears in the last position.
But I executed the stored procedure from a console, and the object is in the correct position.

May be I have a remark: I'm using the same SQL Connection to execute both stored procedures: insertion and select.
Could this be a problem?
Hi, there!
For two days, I'm struggling with this problem:
I'm developing a Java application.
The program shows an ordered list of objects in a Swing JList. These objects are obtained with a SQL query (SELECT.....ORDER BY...) to a MySQL database.
The user can add an object. This object is inserted on database by mean of "INSERT INTO....".
After the object is inserted in database, the JList is cleared, and the same "SELECT....ORDER BY...." query is executed in order to populate the JList again.
But the added object appears at the end of the list, instead it appear in order.
After I restart the application, the added object appears in correct order.
I can't imagine why this happens.
I don't know SQL and MySQL very well. May be I'm omitting some statements for persists the changes in database... I don't know.

Can sombody help me with this problem?

Thank you, in advance.
2 years ago

Stephan van Hulst wrote:

Adrian Cordoba wrote:This happens because MavenLibraryTest-1.0-SNAPSHOT.jar is not included inside the application's jar.


No, jars shouldn't ever be inside each other. In this case, your library jar should be in the same directory as your application jar. If you want your library to be in some other location, you should use <manifest><classpathPrefix> to specify the path that comes before all your classpath entries. I usually have ../lib/ as I distribute my application in MyApplication/bin and the referenced libraries in MyApplication/lib.

I don't have a quick tutorial. You can check out the Maven POM Reference, and work from there. For deploying applications, check out the Oracle tutorial on deployment.



Thank you, very, very much!
3 years ago

Stephan van Hulst wrote:ItDoesntWorkIsUseless. Please tell us what you've done, what error message you get, and show us the content of the generated manifest. You see can see the manifest by opening the jar with an unzipper.


I beg your pardon.

First, I added the following snippet to the POM (by mean NetBeans):



Then, I "Clean and Build" (NetBeans) the project in order to get the jar.
This is the MANIFEST.MF inside the jar:



When I run the application by mean "java -jar .... " I get the following exception:



Note: The class ar.com.adriancordoba.app.commonlibraries.mavenlibrarytest.Person is in MavenLibraryTest-1.0-SNAPSHOT.jar.
This happens because MavenLibraryTest-1.0-SNAPSHOT.jar is not included inside the application's jar.

Please, can you tell me a good tutorial for learn Maven? (If shorter, the better.)
Maybe I can solve the problem by myself.

Thank you again.
3 years ago

Stephan van Hulst wrote:Try:

If you have any other queries regarding the manifest, check out the link I posted earlier, there is a lot of useful documentation there.



Thank you, but <addClasspath>true</addClasspath> didn't work.
3 years ago

Stephan van Hulst wrote:You shouldn't modify the effective POM. You should modify the real POM. If you overwrite the configuration section of the related plugin, it will also appear in the effective POM.


You are right, Stephan. Thank you very much.
Now, I can run the application with "java -jar ....". But the jar has no dependencies.
Can you help me, in order to include dependencies in the jar?

Thank you, once again.
3 years ago

Stephan van Hulst wrote:Actually, you don't need <manifestEntries>, the maven archiver has a special element for that. So you could use this for your maven-jar-plugin configuration:



How can I do that with NetBeans?
I tried it, but I can't modify effective POM in NetBeans.
I'll appreciate details.

Thank you, very much.
3 years ago
I've developed a Java Application by mean a Maven Project with NetBeans 8.1.
This application run as it's expected on NetBeans environment, using "Run project".
But now, I want to run the application outside NetBeans ,(in production).
By mean "Clean and Build", I get the jar in the maven local repository. But when I try to run this jar, I get:
"no main manifest attribute, in DerquiSystemsManagerFrontEnd-1.0-SNAPSHOT.jar"

How can I get a runnable jar from a Maven Project in NetBeans?
(I do not know much about Maven.)

Thank you, in advance.
3 years ago

E Armitage wrote:You can use the maven-assembly-plugin to create the executable jar. See the last section of the docs here



Thank you, E Armitage.
Also, I found this way:


Thank you, anyway.
4 years ago
Hi there!
I had created a new "Maven Project", skipping the archetype selection, on Eclipse Luna.
Then I added packages and classes to my project normally.
How can I add a main class to the Maven configuration (pom.xml) in order to Maven install a runnable jar?

Thank you in advance.
4 years ago
Please, can anyone recommend a good tutorial about Java Web Services with Eclipse?
(I'm a Java Developer, but I don't know about Web Services.)

Thank you in advance.
4 years ago

Ulf Dittmer wrote:You seem to assume that lines 11 and 12 of the DecrementThread and IncrementThread are executed atomically, but they're not. It's perfectly possible (likely, in fact), that threads are switched between lines 11 and 12.



Thank you, Ulf Dittmer.
Now, I understand.
Hi, all!
I've been studying concurrent programming from Oracle Documentation. And I was testing some code from that tutorial:
I have a class with a field that can be incremented or decremented:

And two Thread classes for create threads: One of them for increment the Counter's value, and the other one for decrement it:


Finally, I coded a main class that creates two threads (IncrementThread and DecrementThread) with the same Counter object, and start them:

I understand when I run this little application that the printed values in console are not consistent:


Decrement thread: value = 8385
Increment thread: value = 8388
Increment thread: value = 8385
Increment thread: value = 8386
Increment thread: value = 8387
Decrement thread: value = 8384
Increment thread: value = 8388



But, what I cannot understand is that something similar happens when I synchronize the access methods to the field "value" of the Counter class (Synchronized Methods):

With synchronized methods I get the same thing:


Decrement thread: value = 1989
Decrement thread: value = 1988
Decrement thread: value = 1987
Decrement thread: value = 1986
Increment thread: value = 1990
Decrement thread: value = 1985
Decrement thread: value = 1985
Decrement thread: value = 1984



Can someone tell me what's happening?
(Details are welcome.)

Thank you, in advance.
Thank you, Bear Bibeault!
It works throwing ServletException and then the container catched it by mean deployment descriptor with <exception-type> tag to pass control to JSP error page.
5 years ago
JSP
OK, I'll try it.
Thank you very much!
5 years ago
JSP