Board index » jbuilder » How do I enable assertions in JBuilder Foundation ?

How do I enable assertions in JBuilder Foundation ?


2005-09-21 10:43:20 AM
jbuilder17
How do I enable assertions in JBuilder Foundation ?
Thank you in advance
 
 

Re:How do I enable assertions in JBuilder Foundation ?

Quote
>>Which JDK are you developinf in/for?
I am using jdk 1.5.0_03
Quote
>Have you changed the project properties to that jdk?
I looked under "project properties" and "default project properties and did not see anything about "assertions"
Your advice is appreciated
"Paul Nichols [TeamB]" < XXXX@XXXXX.COM >wrote:
Quote
Stan Dominski wrote:
>>>>
>How do I enable assertions in JBuilder Foundation ?
>
>Thank you in advance

Which JDK are you developinf in/for? Have you changed the project properties
to that jdk?

 

Re:How do I enable assertions in JBuilder Foundation ?

(Credit to Lori Olson for solving this for me previously)
Project-->Project Properties-->Run-->New (or edit, if you've run the project
already)-->fill in -ea in the VM parameters field. You also need to have set
the project Path to point to JDK 1.4 or higher, and used Build/Java to set
the language features and target VM to 1.4 or higher.
Joe
"Stan Dominski" < XXXX@XXXXX.COM >wrote in message
Quote

>>>Which JDK are you developinf in/for?

I am using jdk 1.5.0_03

>>Have you changed the project properties to that jdk?

I looked under "project properties" and "default project properties and
did not see anything about "assertions"

Your advice is appreciated







"Paul Nichols [TeamB]" < XXXX@XXXXX.COM >wrote:
>Stan Dominski wrote:
>>>>>
>>How do I enable assertions in JBuilder Foundation ?
>>
>>Thank you in advance
>
>Which JDK are you developinf in/for? Have you changed the project
>properties
>to that jdk?
>

 

{smallsort}

Re:How do I enable assertions in JBuilder Foundation ?

(Credit to Lori Olson for solving this for me previously)
Quote
>>Project-->Project Properties-->Run-->New (or edit,
I didn't see that but I did do:
Project
Project Properties
on the left I selected
Build
Java
Language Features
1.5 Generics enabled
Quote
>>if you've run the project already)
-->fill in -ea in the VM parameters field.
I found Under
Project
Project Properties
Build
Java
Target VM "Java 2 , V5.0 and later"
Quote
>>You also need to have set the project Path to point to JDK 1.4 or higher,
That part I did when I downloaded the jdk1.5.0_03
Quote
>>and used Build/Java to set the language features and target VM to 1.4 or higher.
That part is done.
If you can help me discover in the program below why the assertion statement is not working I would appreciate it.
God bless you
. . . . . . . . . . . . . . . .
import java.util.Scanner;
public class TryAssertions
{
public static void main(String[] args)
{
int daysInMonth = 0;
Scanner myScan = new Scanner(System.in);
System.out.println("Please type in the number of days this month: ");
daysInMonth = myScan.nextInt();
if (daysInMonth == 28 || daysInMonth == 29)
{
System.out.println("Month is February");
}
else if (daysInMonth == 30)
{
System.out.println("Month is April, June, September or November");
}
else if(daysInMonth == 31)
{
System.out.println("Month is January, March, May, July, August, October, or December.");
}
else
{
System.out.println("Incorrect entry, program will now exit.");
assert false;
}
System.out.println("The assert statement did not end the program. This is the last executable statement");
}
}
/* the output I reveived is:
Please type in the number of days this month:
23
Incorrect entry, program will now exit.
The assert statement did not end the program. This is the last executable statement
*/
"Joe K" < XXXX@XXXXX.COM >wrote:
Quote
(Credit to Lori Olson for solving this for me previously)

Project-->Project Properties-->Run-->New (or edit, if you've run the project
already)-->fill in -ea in the VM parameters field. You also need to have set
the project Path to point to JDK 1.4 or higher, and used Build/Java to set
the language features and target VM to 1.4 or higher.

Joe

"Stan Dominski" < XXXX@XXXXX.COM >wrote in message
news:433161bc$ XXXX@XXXXX.COM ...
>
>>>>Which JDK are you developinf in/for?
>
>I am using jdk 1.5.0_03
>
>>>Have you changed the project properties to that jdk?
>
>I looked under "project properties" and "default project properties and
>did not see anything about "assertions"
>
>Your advice is appreciated
>
>
>
>
>
>
>
>"Paul Nichols [TeamB]" < XXXX@XXXXX.COM >wrote:
>>Stan Dominski wrote:
>>>>>>
>>>How do I enable assertions in JBuilder Foundation ?
>>>
>>>Thank you in advance
>>
>>Which JDK are you developinf in/for? Have you changed the project
>>properties
>>to that jdk?
>>
>


 

Re:How do I enable assertions in JBuilder Foundation ?

If I was running my program at the Window Console instead
of JBuilder I would simply say:
C:>javac -ea MyProgram.java
How do I do this in JBuilder Foundation IDE ?
Thank you
"Stan Dominski" < XXXX@XXXXX.COM >wrote:
Quote

(Credit to Lori Olson for solving this for me previously)

>>>Project-->Project Properties-->Run-->New (or edit,

I didn't see that but I did do:

Project
Project Properties

on the left I selected

Build
Java
Language Features
1.5 Generics enabled



>>>if you've run the project already)
-->fill in -ea in the VM parameters field.

I found Under
Project
Project Properties
Build
Java
Target VM "Java 2 , V5.0 and later"


>>>You also need to have set the project Path to point to JDK 1.4 or higher,

That part I did when I downloaded the jdk1.5.0_03

>>>and used Build/Java to set the language features and target VM to 1.4 or higher.

That part is done.

If you can help me discover in the program below why the assertion statement is not working I would appreciate it.

God bless you
. . . . . . . . . . . . . . . .


import java.util.Scanner;

public class TryAssertions
{
public static void main(String[] args)
{

int daysInMonth = 0;
Scanner myScan = new Scanner(System.in);
System.out.println("Please type in the number of days this month: ");
daysInMonth = myScan.nextInt();

if (daysInMonth == 28 || daysInMonth == 29)
{
System.out.println("Month is February");
}

else if (daysInMonth == 30)
{
System.out.println("Month is April, June, September or November");
}

else if(daysInMonth == 31)
{
System.out.println("Month is January, March, May, July, August, October, or December.");
}

else
{
System.out.println("Incorrect entry, program will now exit.");
assert false;
}
System.out.println("The assert statement did not end the program. This is the last executable statement");

}
}
/* the output I reveived is:

Please type in the number of days this month:
23
Incorrect entry, program will now exit.
The assert statement did not end the program. This is the last executable statement
*/










"Joe K" < XXXX@XXXXX.COM >wrote:
>(Credit to Lori Olson for solving this for me previously)
>
>Project-->Project Properties-->Run-->New (or edit, if you've run the project
>already)-->fill in -ea in the VM parameters field. You also need to have set
>the project Path to point to JDK 1.4 or higher, and used Build/Java to set
>the language features and target VM to 1.4 or higher.
>
>Joe
>
>"Stan Dominski" < XXXX@XXXXX.COM >wrote in message
>news:433161bc$ XXXX@XXXXX.COM ...
>>
>>>>>Which JDK are you developinf in/for?
>>
>>I am using jdk 1.5.0_03
>>
>>>>Have you changed the project properties to that jdk?
>>
>>I looked under "project properties" and "default project properties and
>>did not see anything about "assertions"
>>
>>Your advice is appreciated
>>
>>
>>
>>
>>
>>
>>
>>"Paul Nichols [TeamB]" < XXXX@XXXXX.COM >wrote:
>>>Stan Dominski wrote:
>>>>>>>
>>>>How do I enable assertions in JBuilder Foundation ?
>>>>
>>>>Thank you in advance
>>>
>>>Which JDK are you developinf in/for? Have you changed the project
>>>properties
>>>to that jdk?
>>>
>>
>
>

 

Re:How do I enable assertions in JBuilder Foundation ?

What version of JBuilder are you running? In X, 2005 and 2006, when I choose
Project-->Project Properties, I see an option of Run in the left pane -
selecting it causes a Runtime Configurations window to open. That's where
you choose new (or edit) and supply -ea to the VM. The other steps that
you've completed allow the assert statements to be recognized
syntactically - editing the runtime configuration is what tells the VM to
execute the statements at runtime (asserts are disabled in the VM by
default - that's Sun's default).
You can go directly to the Runtime Configurations window by choosing
Run-->Configurations - continue from "choose New (or edit..."
Once you get things set properly, note that you can use Default Project
Properties to cause all future projects that you create to have asserts
enabled by default, if that would be appropriate.
Joe
"Stan Dominski" < XXXX@XXXXX.COM >wrote in message
Quote

(Credit to Lori Olson for solving this for me previously)

>>>Project-->Project Properties-->Run-->New (or edit,

I didn't see that but I did do:

Project
Project Properties

on the left I selected

Build
Java
Language Features
1.5 Generics enabled



>>>if you've run the project already)
-->fill in -ea in the VM parameters field.

I found Under
Project
Project Properties
Build
Java
Target VM "Java 2 , V5.0 and later"


>>>You also need to have set the project Path to point to JDK 1.4 or
>>>higher,

That part I did when I downloaded the jdk1.5.0_03

>>>and used Build/Java to set the language features and target VM to 1.4 or
>>>higher.

That part is done.

If you can help me discover in the program below why the assertion
statement is not working I would appreciate it.

God bless you
. . . . . . . . . . . . . . . .


import java.util.Scanner;

public class TryAssertions
{
public static void main(String[] args)
{

int daysInMonth = 0;
Scanner myScan = new Scanner(System.in);
System.out.println("Please type in the number of days this month: ");
daysInMonth = myScan.nextInt();

if (daysInMonth == 28 || daysInMonth == 29)
{
System.out.println("Month is February");
}

else if (daysInMonth == 30)
{
System.out.println("Month is April, June, September or November");
}

else if(daysInMonth == 31)
{
System.out.println("Month is January, March, May, July, August,
October, or December.");
}

else
{
System.out.println("Incorrect entry, program will now exit.");
assert false;
}
System.out.println("The assert statement did not end the program. This
is the last executable statement");

}
}
/* the output I reveived is:

Please type in the number of days this month:
23
Incorrect entry, program will now exit.
The assert statement did not end the program. This is the last executable
statement
*/

 

Re:How do I enable assertions in JBuilder Foundation ?

Stan Dominski wrote:
Quote
Build
Java
Language Features
1.5 Generics enabled
OK so far. Now since you're running Foundation, you only have the one
run configuration, so under Project Properties, select "Run". If the
table to the right is empty, click on "New...", else click on "Edit...".
In the "VM parameters" field, add "-ea" (or "-enableassertions"). And
any other VM parameters you'd like to add, while you're about it.
 

Re:How do I enable assertions in JBuilder Foundation ?

Stan Dominski wrote:
Quote


How do I enable assertions in JBuilder Foundation ?

Thank you in advance
Which JDK are you developinf in/for? Have you changed the project properties
to that jdk?
 

Re:How do I enable assertions in JBuilder Foundation ?

Dear Joe K and Shankar Unni,
Thank you very much for your instructions.
My program works OK now. Here is the correct output I received :
Please type in the number of days this month:
23
Exception in thread "main" java.lang.AssertionError
at stan_try_assertions.TryAssertions.main(TryAssertions.java:36)
Incorrect entry, program will now exit.
Your help is appreciated !
God bless you all
Stan
"Stan Dominski" < XXXX@XXXXX.COM >wrote:
Quote

If I was running my program at the Window Console instead
of JBuilder I would simply say:

C:>javac -ea MyProgram.java

How do I do this in JBuilder Foundation IDE ?

Thank you













"Stan Dominski" < XXXX@XXXXX.COM >wrote:
>
>(Credit to Lori Olson for solving this for me previously)
>
>>>>Project-->Project Properties-->Run-->New (or edit,
>
>I didn't see that but I did do:
>
>Project
>Project Properties
>
>on the left I selected
>
>Build
>Java
>Language Features
>1.5 Generics enabled
>
>
>
>>>>if you've run the project already)
>-->fill in -ea in the VM parameters field.
>
>I found Under
>Project
>Project Properties
>Build
>Java
>Target VM "Java 2 , V5.0 and later"
>
>
>>>>You also need to have set the project Path to point to JDK 1.4 or higher,
>
>That part I did when I downloaded the jdk1.5.0_03
>
>>>>and used Build/Java to set the language features and target VM to 1.4 or higher.
>
>That part is done.
>
>If you can help me discover in the program below why the assertion statement is not working I would appreciate it.
>
>God bless you
>. . . . . . . . . . . . . . . .
>
>
>import java.util.Scanner;
>
>public class TryAssertions
>{
>public static void main(String[] args)
>{
>
>int daysInMonth = 0;
>Scanner myScan = new Scanner(System.in);
>System.out.println("Please type in the number of days this month: ");
>daysInMonth = myScan.nextInt();
>
>if (daysInMonth == 28 || daysInMonth == 29)
>{
>System.out.println("Month is February");
>}
>
>else if (daysInMonth == 30)
>{
>System.out.println("Month is April, June, September or November");
>}
>
>else if(daysInMonth == 31)
>{
>System.out.println("Month is January, March, May, July, August, October, or December.");
>}
>
>else
>{
>System.out.println("Incorrect entry, program will now exit.");
>assert false;
>}
>System.out.println("The assert statement did not end the program. This is the last executable statement");
>
>}
>}
>/* the output I reveived is:
>
>Please type in the number of days this month:
>23
>Incorrect entry, program will now exit.
>The assert statement did not end the program. This is the last executable statement
>*/
>
>
>
>
>
>
>
>
>
>
>"Joe K" < XXXX@XXXXX.COM >wrote:
>>(Credit to Lori Olson for solving this for me previously)
>>
>>Project-->Project Properties-->Run-->New (or edit, if you've run the project
>>already)-->fill in -ea in the VM parameters field. You also need to have set
>>the project Path to point to JDK 1.4 or higher, and used Build/Java to set
>>the language features and target VM to 1.4 or higher.
>>
>>Joe
>>
>>"Stan Dominski" < XXXX@XXXXX.COM >wrote in message
>>news:433161bc$ XXXX@XXXXX.COM ...
>>>
>>>>>>Which JDK are you developinf in/for?
>>>
>>>I am using jdk 1.5.0_03
>>>
>>>>>Have you changed the project properties to that jdk?
>>>
>>>I looked under "project properties" and "default project properties and
>>>did not see anything about "assertions"
>>>
>>>Your advice is appreciated
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>"Paul Nichols [TeamB]" < XXXX@XXXXX.COM >wrote:
>>>>Stan Dominski wrote:
>>>>>>>>
>>>>>How do I enable assertions in JBuilder Foundation ?
>>>>>
>>>>>Thank you in advance
>>>>
>>>>Which JDK are you developinf in/for? Have you changed the project
>>>>properties
>>>>to that jdk?
>>>>
>>>
>>
>>
>