Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-31-2007, 07:26 PM
Member
 
Join Date: Jul 2007
Posts: 5
aleplgr is on a distinguished road
why does not execute this?
Hi! In this code I print one message before and after executing the method obtenirInstanciaUnica, those 2 messages are actually displayed in the console, so far so good:

Code:
private void jbInit() throws Exception { System.out.println("before obtenirInstanciaUnica"); gestor = GestorKlass.obtenirInstanciaUnica(Integer.parseInt(param.obtenirMaximMatrius())); System.out.println("after obtenirInstanciaUnica");
Here's the method, in the constructor GestorKlass I try to display a message

Code:
public static synchronized GestorKlass obtenirInstanciaUnica(int maxMats){ System.out.println("I AM HEREEEEEEE"); if (instancia == null) instancia = new GestorKlass(maxMats); return instancia; } private GestorKlass(int max){ System.out.println("I AM CONSTRUCTING HERE"); maxMatrius = max; numMatriusOcupades = 0; matriusCarregades = new GestorMatriu[maxMatrius]; }
The question is WHY does not it write anything else to the console? it should show the message in the obtenirInstanciaUnica method first line, and also the message in the constructor, seems as if this method is not executed, but it is because It returns the gestor variable which is used all around the rest of the program and it works fine, I don't understand ..

Last edited by levent : 07-31-2007 at 09:07 PM. Reason: Codes are placed inside [code] tag.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-31-2007, 09:11 PM
Senior Member
 
Join Date: Jul 2007
Posts: 134
brianhks will become famous soon enough
Very odd. My suspicion is that the problem lies outside the code you have presented. Can you post the entire GestorKlass?
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-31-2007, 09:47 PM
Senior Member
 
Join Date: Dec 2006
Posts: 748
levent is on a distinguished road
Make sure you recompile the project properly. I think you should try deleting all class files and recompiling the sources.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 08-01-2007, 03:27 AM
Member
 
Join Date: Jul 2007
Location: Las Vegas
Posts: 14
Sircedric88 is on a distinguished road
Send a message via AIM to Sircedric88
haha i cant believe noone saw it, but after you declare what condition the if statement must meet you need curly braces.

if (condition)
{
Do stuff here;
}
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 08-01-2007, 05:38 AM
Senior Member
 
Join Date: Jul 2007
Posts: 134
brianhks will become famous soon enough
That is incorrect.
Code:
if (condition) Do this;
Is perfectly valid code. Braces are only required if the code in the condition is more then one line.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 08-01-2007, 05:44 AM
Member
 
Join Date: Jul 2007
Location: Las Vegas
Posts: 14
Sircedric88 is on a distinguished road
Send a message via AIM to Sircedric88
Oh really? thanks i never knew
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 08-01-2007, 12:37 PM
Member
 
Join Date: Jul 2007
Posts: 5
aleplgr is on a distinguished road
Thanks, I deleted the class files and recompiled and it works fine now!!
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

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 On


Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot execute EJB application. JavaEmpires Enterprise JavaBeans 0 03-08-2008 09:58 AM
Execute Jar file barney New To Java 1 08-07-2007 08:13 AM
My application Will Not Execute romina New To Java 1 08-07-2007 06:16 AM
problems when I try to execute a jsp page christina JavaServer Pages (JSP) and JSTL 2 08-01-2007 01:23 PM
Execute a new program in java mathias Advanced Java 1 07-31-2007 06:42 AM


All times are GMT +3. The time now is 10:43 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org