• 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

Unable to Run A Java Program Thar uses java.util.regex package

 
Greenhorn
Posts: 21
Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
I was trying to execute a regular Expression program that was given as an example from the "The Complete Reference :Java 2 Fifth Edition " Book. I typed the program in a Notepad and Compiled it in Command Prompt.
Source Code


Although i could compile the above program successfully . I wasn't able to run it in the Command prompt with the Command :

java Regexp3

Error: Could not find or load main class Regexp3

It would be great if anyone could tell me how exactly can i execute this program in command prompt .

Thanks in Advance


Regards,
Kasiraj
 
Saloon Keeper
Posts: 15510
363
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you put the class file in the correct directory with regards to its package? Did you set the CLASSPATH variable?
 
Kasiraj Murugesa pandian
Greenhorn
Posts: 21
Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Did you put the class file in the correct directory with regards to its package? Did you set the CLASSPATH variable?



Thanks A lot for Letting me know about the Classpath variable. Actually i have set the Classpath variable for Apache Tomcat when i tried to execute a servlet program without using Netbeans . So only after you've told me about it, i just remembered it and removed the Classpath and now it uses the previous classpath that i gave for java .

Thanks Again !

But is it really possible to Set two Classpath Variables ?. If so how do we set them ?.



Regards,
Kasiraj
 
Marshal
Posts: 79179
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's better to set a classpath for each application, because each application will require a different classpath. We have an FAQ about it.
Try something like set CLASSPATH=.;C:\myFolder\myJar.jar at the command line, which will set it for the lifetime of that command window. Note that syntax won't work on Linux/Mac/Unix, which use the keyword "export".
 
Rancher
Posts: 43081
77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Actually i have set the Classpath variable for Apache Tomcat


Tomcat does not use the CLASSPATH variable.

But is it really possible to Set two Classpath Variables ?.


No, there is only a single CLASSPATH variable. You can have multiple terminal windows/shells, though, and each can have its own CLASSPATH.

I generally advise never to use the CLASSPATH variable, it's more trouble than it's worth. Better to list the required libraries with a "-cp" switch when using javac or java. If there are too many libraries to make this practical, consider using Ant.
 
Kasiraj Murugesa pandian
Greenhorn
Posts: 21
Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:Actually i have set the Classpath variable for Apache Tomcat
Tomcat does not use the CLASSPATH variable.



In setting the Classpath for tomcat , i meant to include the library file i.e for the servlet-api file that is located in tomcat/common/lib/ . i guess we can do that . Sorry to be not much specific about it

Thanks Anyways

 
Kasiraj Murugesa pandian
Greenhorn
Posts: 21
Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you All For your Valuable information that helped me Execute my Regular expression Program .



Thanks Again


Regards,
Kasiraj
 
Campbell Ritchie
Marshal
Posts: 79179
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome
 
You get good luck from rubbing the belly of a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic