• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Enable assertion at complie time

 
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using Java 1.4 and can enable assertion at runtime by going to Windows-Preferences, editing the select jre and putting -ea in arguments text box.

But I want to enable assert at compile time as well..that is I want to achieve the following.

javac -source 1.4 ClassName.java

Thank you,
Himalay majumdar
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should be able to simply add the -ea option to the javac command line, but it will not do what I think you want. It will turn assertions on within the compiler itself (if the compiler contains any), but has no impact on your compiled code. There is no way I know of to compile a Java source file such that the assertions it contains are permanently on.
 
Himalay Majumdar
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You should be able to simply add the -ea option to the javac command line



I cud just find "java command line arguments" NOT "javac command line arguments" in eclipse

Is it true that eclipse uses its own compiler, not javac. And if we want to add "javac command line arguments" we need to use script files like ant or maven.

Thanks
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can change the settings to accept compile level to java5 ( in windows-->preferences-->java-->compile)
 
Himalay Majumdar
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yeah..thats a workaround but I was curious to know managing "javac command line arguments" in eclipse
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ahah, there's your problem - you are trying to do this in Eclipse (your original post never mentioned Eclipse). I do all of my builds in Ant or Maven.

You could try creating a new builder from, your project (Project > Properties > Builders). Choose a "Program" builder and then provide the information for javac and its options. Then uncheck the "Java Builder" for your project and check only your new builder.
 
Himalay Majumdar
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for that, I assumed eclipse to be the default ide here.
Thank you for the information
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, because you never mentioned any IDE, if I would have been a moderator in this forum I would have move you to the Java(intermediate) forum.
 
Ranch Hand
Posts: 182
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
deleted
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic