• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Kasiraj Murugesa pandian
Greenhorn
Posts: 21
Java Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Stephan van Hulst
Bartender
Pie
Posts: 4826
34
Chrome Netbeans IDE Windows
  • 1
  • Mark post as helpful
  • send pies
  • 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
Java Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Campbell Ritchie
Sheriff
Pie
Posts: 47229
52
  • 1
  • Mark post as helpful
  • send pies
  • 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".
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 1
  • Mark post as helpful
  • send pies
  • 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
Java Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • 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
Java Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Pie
Posts: 47229
52
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic