my dog learned polymorphism*
The moose likes Beginning Java and the fly likes java.util.regex? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java.util.regex?" Watch "java.util.regex?" New topic
Author

java.util.regex?

Douglas Kent
Ranch Hand

Joined: Oct 06, 2000
Posts: 171
Hello,
I'm trying to use the regex class and cannot find it in the downloaded j2se1.4 from java.sun. Has anyone been able to get this to load? Which jar file?
thanks,
Max Habibi
town drunk
( and author)
Sheriff

Joined: Jun 27, 2002
Posts: 4118
Dougles,
I'm suprised that you're having this probem: I didn't. Can use, say, java.util.*?
M


Java Regular Expressions
Douglas Kent
Ranch Hand

Joined: Oct 06, 2000
Posts: 171
Yes, can use java.util, just not java.util.regex.Pattern.
Max Habibi
town drunk
( and author)
Sheriff

Joined: Jun 27, 2002
Posts: 4118
Just to eliminate the obvious: did you do a java -version ? Did you reboot after the install? And if so, what exact error message are you getting?
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Yeah, it does seem most likely that though you've downloaded 1.4, you're still running 1.3. It's also possible that the java command runs 1.4, but javac could point to 1.3. (I'm not sure why, but I've seen it happen.) Try temporarily renaming the directory your old 1.3 version is in, to see if you're still using anything in it without realizing it. You may need to hand edit the system PATH to find j2sdk1.4.0\bin, which is where your java commands should be.
To answer another question, you can probably find the Regex class in j2sdk1.4.0\jre\lib\rt.jar. That's for Windows anyway; it's probably about the same (except for the slashes) on unix.


"I'm not back." - Bill Harding, Twister
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
What does your classpath environment variable look like?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Douglas Kent
Ranch Hand

Joined: Oct 06, 2000
Posts: 171
Finally found the class, but now getting another problem:
java.lang.SecurityException: Prohibited package name: java.util.regex
at java.lang.ClassLoader.defineClass(ClassLoader.java:477)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
at sax.Splitter.main(Splitter.java:22)
HERE'S THE CODE:
import java.util.regex.*;
public class Splitter {
public static void main(String args[]) {
// Create a pattern to match breaks
Pattern p = null;
p = Pattern.compile("[,\\s]+");
"compile" is a static method of the Pattern class. Why would java do this check? Is this new in 1.4?
Max Habibi
town drunk
( and author)
Sheriff

Joined: Jun 27, 2002
Posts: 4118
Doug,
IFIK, this is not a problem of 1.4. I've installed on over 150 (windows)machines, and it's been a pretty smooth ride. I suggest that you uninstall, then install again.
M
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: java.util.regex?