The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Java Help
|
Static void is not being reached
Discuss Static void is not being reached in the Java Help forum on Dev Shed. Static void is not being reached Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics.
|
|
 |
|
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

February 28th, 2013, 07:22 PM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 20
Time spent in forums: 2 h 46 m 50 sec
Reputation Power: 0
|
|
Static void is not being reached
When the main void executes this:
Code:
public static void load(){
DialogueHandler.sendText1("test");
}
SendText1:
Code:
public static void sendText1(String text){
Logger.log("done"); //Test if void was reached
Window.jTextArea1.append(text + newLine);
}
The application completely stops at this point in the load void and nothing is logged nor added to the TextArea. Why is this happening?
EDIT: They are in separate classes
|

March 1st, 2013, 09:06 AM
|
 |
Java Junkie
|
|
Join Date: Jan 2004
Location: Mobile, Alabama
|
|
|
Do you call them from the main method?
|

March 1st, 2013, 11:39 AM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 20
Time spent in forums: 2 h 46 m 50 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by bullet Do you call them from the main method? |
No doesn't work
|

March 1st, 2013, 11:42 AM
|
 |
Java Junkie
|
|
Join Date: Jan 2004
Location: Mobile, Alabama
|
|
Quote: | Originally Posted by fantity No doesn't work |
If it's an application, nothing is going to be executed unless it's called by the main method.
|

March 1st, 2013, 11:49 AM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 20
Time spent in forums: 2 h 46 m 50 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by bullet If it's an application, nothing is going to be executed unless it's called by the main method. |
It is;
Main method:
Code:
public static void main(String[] args){
load();
}
|

March 1st, 2013, 12:45 PM
|
 |
Java Junkie
|
|
Join Date: Jan 2004
Location: Mobile, Alabama
|
|
Quote: | Originally Posted by fantity It is;
Main method:
Code:
public static void main(String[] args){
load();
}
|
When you say the application stops, does it print an error message?
|

March 1st, 2013, 12:51 PM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 20
Time spent in forums: 2 h 46 m 50 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by bullet When you say the application stops, does it print an error message? |
There's no error message even with Try & Catch
|

March 1st, 2013, 01:16 PM
|
 |
Contributing User
|
|
Join Date: Aug 2010
Location: SW Missouri
|
|
|
Add some printlns to print out messages at every statement that you expect to execute.
The last message printed out will show you where the last statement executed was.
You'll know that execution stopped before the next println was executed because its message won't have printed.
|

March 1st, 2013, 03:17 PM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 20
Time spent in forums: 2 h 46 m 50 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by NormR Add some printlns to print out messages at every statement that you expect to execute.
The last message printed out will show you where the last statement executed was.
You'll know that execution stopped before the next println was executed because its message won't have printed. |
I have done that and it doesn't print or continue after the sendText void.
|

March 1st, 2013, 03:31 PM
|
 |
Contributing User
|
|
Join Date: Aug 2010
Location: SW Missouri
|
|
|
I'm not sure where the printlns are located from what you've said. I don't see a "sendText void". I do see void sentText1( in two places: one where it is called and one where it is defined.
What is the last println() that is printed? What println is not printed?
Post the code that shows where the printlns are located in the code
and post the output from the program running when it prints out the messages.
|

March 1st, 2013, 03:49 PM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 20
Time spent in forums: 2 h 46 m 50 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by NormR I'm not sure where the printlns are located from what you've said. I don't see a "sendText void". I do see void sentText1( in two places: one where it is called and one where it is defined.
What is the last println() that is printed? What println is not printed?
Post the code that shows where the printlns are located in the code
and post the output from the program running when it prints out the messages. |
Code:
public static void load(){
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setVisible(true);
System.out.println("done1");
DialogueHandler.sendText1("test");
System.out.println("done2");
}
public static void sendText1(String text){
System.out.println("done3");
Window.jTextArea1.append(text + newLine);
}
Output:

|

March 1st, 2013, 03:58 PM
|
 |
Contributing User
|
|
Join Date: Aug 2010
Location: SW Missouri
|
|
|
It looks like there is another version of the method that is being called instead of the code you posted. Otherwise done3 would print.
|

March 1st, 2013, 03:59 PM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 20
Time spent in forums: 2 h 46 m 50 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by NormR It looks like there is another version of the method that is being called instead of the code you posted. Otherwise done3 would print. |
Except it doesn't.
|

March 1st, 2013, 04:07 PM
|
 |
Contributing User
|
|
Join Date: Aug 2010
Location: SW Missouri
|
|
|
Make a small complete program that compiles, executes and shows the problem and paste it here so we can test it.
|

March 1st, 2013, 04:14 PM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 20
Time spent in forums: 2 h 46 m 50 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by NormR Make a small complete program that compiles, executes and shows the problem and paste it here so we can test it. |
Do you have skype?
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|