Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Apr 9, 2007, 09:32 PM   #1
ScKaSx
macrumors regular
 
Join Date: Feb 2006
java assertion compiling error

I am trying to compile an example for java from THE REALLY BIG INDEX:
http://java.sun.com/docs/books/tutor...ples/Card.java

However whenever I try to compile:
javac Card.java
I get the following error:
"warning: as of release 1.4, assert is a keyword, and may not be used as an identifier"

And if I try to compile it with enable assertions I get:
javac: invalid flag: -ea
Usage: javac <options> <source files>

Any ideas on how to get this code to compile? I am running Java version 1.4.2_12, which I believe should be able to handle assertions. Thanks for your help.

Cheers,
ScKaSx
ScKaSx is offline   0 Reply With Quote
Old Apr 9, 2007, 11:58 PM   #2
therevolution
macrumors 6502
 
Join Date: May 2003
Warning messages aren't fatal. If that's all you saw, then the compile was probably successful. Do you see a Card.class in that directory? If so, then you don't need to do anything about the warning.

Also, while I didn't actually try this (nor have I ever used assertions in Java), it looks like you add the '-ea' flag when running your program, not when compiling it. Like this:
Code:
java -ea Card
More info on assert here.
therevolution is offline   0 Reply With Quote
Old Apr 10, 2007, 10:49 AM   #3
aLoC
macrumors 6502a
 
Join Date: Nov 2006
From memory, I think it's something like
javac -source 1.4

Then it will understand the asserts as being asserts and not a variable named assert.
aLoC is offline   0 Reply With Quote
Old Apr 10, 2007, 04:14 PM   #4
ScKaSx
Thread Starter
macrumors regular
 
Join Date: Feb 2006
Thanks -source 1.4 works!

Hey Guys,

Thanks for the response. What worked for me was aloc's suggestion to compile with the flag -source 1.4. Thanks again.

Cheers,
ScKaSx
ScKaSx is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Mac mini Java Installation Error Dekema2 Mac mini 4 Feb 10, 2014 02:43 PM
-fobjc-arc is not supported error and duplicate symbol error in compiling mehdies Mac Programming 3 Sep 24, 2013 02:57 AM
Java error Appl3FTW MacBook Pro 3 Aug 21, 2013 07:53 PM
java security error only when a box is checked Corrosive vinyl Mac Applications and Mac App Store 0 Jun 6, 2013 11:07 AM
General: How-to-Fix TinyUmbrella Java Error 5.11.00 and above. SmartiOS Jailbreaks and iOS Hacks 1 Oct 20, 2012 05:15 AM

Forum Jump

All times are GMT -5. The time now is 08:01 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC