wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Assertion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Assertion" Watch "Assertion" New topic
Author

Assertion

MI Mohammed
Ranch Hand

Joined: Feb 16, 2005
Posts: 146
Can somebody tell me what is the mode for javac, when compilin codes with assertions. I tried it and what i got was a compiler error and warning but when i compile the same code with javac -source 1.4, it compilled. :roll:


SCJA(Beta) SCJP 1.4 SCWCD 1.4 SCBCD 1.3 SCBCD 5.0 beta <br />The more practice we get, the better we are at the exams and in life in general. Pls join me at My DEN.
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
You have it right. You must specify -source 1.4 to compile assertions with the Java 1.4 compiler.


Mike Gershman
SCJP 1.4, SCWCD in process
Jesse Torres
Ranch Hand

Joined: Mar 25, 2004
Posts: 985
Originally posted by Mike Gershman:
You have it right. You must specify -source 1.4 to compile assertions with the Java 1.4 compiler.


How do you run the code. I successfully compiled with:

javac -source 1.4 AssertionTest.java

However when trying to run, I receive:
"Exception in thread main java.lang.NoClassDefFoundError:

I have tried running as:
java AssertionTest
java -ea AssertionTest
Jay Pawar
Ranch Hand

Joined: Aug 27, 2004
Posts: 411
Could you please post your code ?


Cheers,<br />Jay<br /> <br />(SCJP 1.4)<br />Heights of great men were not achieved in one day, they were toiling day and night while their companions slept.
Jesse Torres
Ranch Hand

Joined: Mar 25, 2004
Posts: 985
Originally posted by Jay Pawar:
Could you please post your code ?




Thanks,
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
Is your classpath set?
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228

Your class is inside the package scjp. So should it not be in this way ?

java scjp.AssertionTest

[ February 16, 2005: Message edited by: srini vasan ]

Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
Jesse Torres
Ranch Hand

Joined: Mar 25, 2004
Posts: 985


I can easily compile class with:
C:\devel\scjp> javac -source 1.4 AssertionTest.java

The preceding line successfully compiles. However the following commands generate errors:

C:\devel\scjp> java -ea AssertionTest

or

c:\devel\scjp> java AssertionTest

The following is the error that is outputed to the command window:


C:\devel\scjp>java -ea AssertionTest
Exception in thread "main" java.lang.NoClassDefFoundError: AssertionTest (wrong
name: scjp/AssertionTest)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)

C:\devel\scjp>

Please help!
[ February 16, 2005: Message edited by: Jesse Torres ]
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
try to go to "C:\devel"
and run the java command java scjp.AssertionTest
Jesse Torres
Ranch Hand

Joined: Mar 25, 2004
Posts: 985
Originally posted by srini vasan:
try to go to "C:\devel"
and run the java command java scjp.AssertionTest


BINGO
That was the problem

I went to:
C:\devel\scjp> javac -source 1.4 Assertion.Test
C:\devel\scjp> java -ea scjp.AssertionTest
successful
C:\devel\scjp>

Thanks for your help srini.
[ February 16, 2005: Message edited by: Jesse Torres ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Assertion
 
Similar Threads
javac error when using jar file : cannot find symbol
errors generated when running Ant build file in Eclipse
Cannot resolve symbol
Collections Frame work
how to compile java prog (there is only one dos not xp,98 ...any)?