debbie collins

Greenhorn
+ Follow
since Oct 11, 2000
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by debbie collins

<pre>
1. Microsoft jvm (java virtual machine) must be installed on your machine. This is free and can be downloaded
2. A reference to XXX.jar must be included in your classpath. Example: ..;C:\WINNT\java\classes\classes.zip;C:\WINNT\java\classes;.;%systemroot%\java\classes;c:\jdk1.3\lib\tools.jar;c:\jdk1.3\jre\lib\rt.jar;c:\jdk1.3\jre\lib\il8n.jar;c:\jdk1.3\jre\lib \ext\jms.jar; c:\Program Files\NewScoringManager\Ace.jar
3. The PATH environment variable must include the "bin" directories for the jdk and the ms sdk.
4. After initial setup, run clspack -auto from c:\ in a DOS window.
Here is an example:
'Get the java log manager
Dim objJavaLogMgr As Object
Set objJavaLogMgr = GetObject("java:com.sierracities.util.VBSingletonAccess")
Dim objJavaLog As Object
Set objJavaLog = objJavaLogMgr.getSingleton( _
"com.sierracities.util.Log")

Good luck. Remember - it uses the Microsoft jvm and is behind JDK1.2
</pre>
22 years ago
Tristan,
I no longer use that method, but rather the getObject(java:com.etc.ClassName) available in VB. This requires only that your class file, com/etc/ClassName.class, or a jar containing it be in your classpath and that there is a no argument constructor for the class.
Microsoft's vm will be invoked and it is not up to JDK1.2, so care must be taken. Usually running with jview first is a good indication.
Good luck,
Debbie
23 years ago
Thanks for the reply. The answer is to parse each string returned looking for entities. > is represented as gt, shown in XML as >. Other special characters are & - &, < - <.
I have a simple XML document that contains "--> " as a value.
<Constant>--> </Constant>
It is read in just fine using jaxp - javax.xml.parsers.DocumentBuilder, but when it is written to a new file using sun.xml.tree.XMLDocument it becomes "--> ". How can I parse this back to "--> "?
Thanks,
Debbie
You can use jaxp to write an XML text file from a Document.
import com.sun.xml.tree.XMLDocument;
import org.w3c.dom.Document;

FileWriter oWriter = new FileWriter( FileName );
((XmlDocument)document).write( oWriter );

I've been trying this out today and it works. I'm having a problem with the header that is generated, however. It is:
<?xml version="1.0" encoding="Cp1252"?>
IE5 doesn't recognize this encoding. Anyone know why or what I can do to make it recognize it?
Singleton is a pattern which ensures that a class has only one instance, and provides a global point of reference to that instance. A good example is a Log class. It is desirable to access the log from any object, but always the same Log object. Rather than pass it around, objects can access the log using:
Log.getInstance.callMethod(..);
There are many examples of Singleton on the web. Search for Singleton Pattern. Also, the Design Patterns book by Gamma, Helm, Johnson, and Vlissides discusses this and other patterns.
Debbie
23 years ago
This was sent by a fellow programmer and it does work. The only problem I'm having now is that the System.loadLibrary in my java stuff can't find the dll. It works fine under Microsoft's jvm or Sun's jvm from the command line, but not when invoked thru VB.
1. your class files must be in a microsoft jvm trusted directory. this is
either WINNT\java\trustlib (or a subdirectory therein) or a directory
specified in the registry key HKLM\SOFTWARE\Microsoft\Java
VM\TrustedClasspath.
2. any other classes that your class needs to access must be in the
microsoft jvm classpath. this is specified in the registry key
HKLM\SOFTWARE\Microsoft\Java VM\Classpath. as an example, i use the
following value for the key (notice the inclusion of the jdk runtimes):
"C:\WINNT\java\classes\classes.zip;%systemroot%\java\classes;..;c:\jdk1.3\li
b\tools.jar;c:\jdk1.3\jre\lib\rt.jar;c:\jdk1.3\jre\lib\i18n.jar;c:\jdk1.3\jr
e\lib\ext\jms.jar".
3. you must have either ms visual j++ or the ms sdk for java installed (so
you can run javareg and clspack).
4. you must have the "bin" directories for the jdk and the ms sdk (or
visual j++) in your PATH environment variable. as an example, i use the
following PATH:
"%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\MSSQL7\BIN
N;C:\jdk1.3\bin;C:\Program Files\Microsoft SDK for Java 4.0\Bin".
5. you must run the following command-line "clspack - auto"; this creates a
package containing some standard classes that the microsoft jvm uses and
puts it in "WINNT\java\classes\classes.zip" (notice it in the Classpath
registry key above).
6. your object cannot rely on java constructors, since they are not
callable from VB. instead, write a function that you call explicitly to do
any initializtion you may need.
Once all of these crieria are met, the following steps are necessary to
register and the java class as a COM object.
1. run javareg. be sure to include the option to create the typelibrary -
if you run the command with /typelib set and it is successfull, you know
that all of your classes/referenced classes are in the proper directories.
if it does not run properly, you know you that you are missing a file
somewhere. this is the ONLY way that i have found to make sure your class
will behave properly as a COM object. as an example, here is a javareg
command line; it assumes that you are at a command prompt in the
WINNT\java\trustlib directory and that your class, named "ImplFoo" is in the
subdirectory com\debbie\foo (WINNT\java\trustlib\com\debbie\foo): "javareg
/register /class:com.debbie.foo.ImplFoo /progid:com.debbie.foo.ImplFoo
/codebase:.\com\debbie\foo\ImplFoo.class
/typelib:.\com\debbie\foo\ImplFoo.tlb".
2. once javareg is successful, use the following line to create the object
in VB (do not include the "java:" prefix):
Dim myJava AS Object
Set myJava = CreateObject("com.debbie.foo.ImplFoo")
NOTES:
- the name specified in CreateObject is whatever you set as the /progid
parameter of javareg - this must match the name you specify in /typelib
(except for the extension)
-if the javareg command fails when you have the /typelib parameter
specified, make sure to do a "javareg /unregister" on the object to clean
out the registry before reattempting to register the object. i have seen
many stray references created in the registry in the past.
23 years ago
I am trying to access my java class from VB (without going the c/jni route). It always stops at CreateObject(java:myClass). I am using the Sun jdk1.3 on Windows2000 with VB6. I tried javareg \register \class:myClass codebase: "c:\mypath" as well as several variations. How can I get VB to be able to create a java object?
Any help would be greatly appreciated.
------------------
23 years ago
It seems like certifications are most useful when new to a subject area. They do not prove true knowledge because even though someone can pass a test, it does not necessarily follow that they can apply the techniques in the test. Sometimes the certification is too broad, also. Altough I have never taken a certification test, I have had no trouble proving my abilities and getting good positions.
Debbie