Wednesday, October 14, 2009

[Jabaco] JaCOB and WScript.Network

I wonder about myself sometimes. Am I sane? For instance, I’ve taken recently to learning and developing with Jabaco. This would seem from one angle, good, and from another, daft. 

Jabaco is a simple programming language with a Visual Basic like syntax. Jabaco enables you to create powerful software for all Java supported operating systems.

So there you have it: a VB6-alike (more or less) syntax targeting the JVM. In my experience, people bagging VB syntax are in the majority. People bagging Java aren’t infrequent either. And I know Java about as well as I know Babylonia Cuneiform.

That said, it’s been a bit of fun figuring things out in Jabaco, and discovering just how effectively one can hook into the Java subsystem.

The code below demonstrates The JACOB Project: A JAva-COM Bridge talking to WScript.Network. Comments are a bit sparse, but VB folk should be able to figure it out quick enough.

Public Sub main(ByJava args() As String)
   Dim myArgs() As String
   myArgs = args
   Dim oShell As ActiveXComponent
'ActiveXComponent is exported by JACOB and referenced in the IDE
'(yes, there’s an IDE, and it’s pretty good too) Set oShell = New ActiveXComponent("WScript.Network") Dim a As String Dim b As String Dim c As String Dim dShell As Dispatch
'Dispatch also part of JACOB. Nice that it uses the standard jargon Set dShell = oShell.getObject() a = Dispatch.call(dShell,"UserDomain") b = Dispatch.call(dShell,"ComputerName") c = Dispatch.call(dShell,"UserName") MsgBox (a & ", " & b & ", " & c) comthread.Release() End Sub

The IDE makes possible ‘compiling’ to an EXE. The code above compiles to about 400K. Of course, the presence of a JRE is implied. And it runs, nicely.

I think I’ll be spending more time with Jabaco. It’s got a lot of promise, especially for the VB-deranged like me.

© Copyright Bruce M. Axtens, 2009.

8 comments:

Anonymous said...
This comment has been removed by a blog administrator.
Bruce M. Axtens said...

The comment was in Chinese and said, "Working hard to blog ~ your blog article terrific!!." However, what followed were lots of links to porn sites. Yuck!!

Anonymous said...

Hallo Bruce,
Thank You for the Your article. I've tested the program (Windows 7, Jacobo 1.5.2, path to jacob.jar added to classpath, jacob.dll in c:\widows\system32) and got the the error
"Converting 'java/lang/Object' to 'com/jacob/com/Dispatch' not possible!"
in line Set dShell = oShell.getObject().

Can You help here. Thank You.
Best regards from Hardo.
16.Jan.2010

Bruce M. Axtens said...

Okay, the version of Jacob I used when writing that was 1.5. Now I've downloaded and installed 1.7 and am having the same problem you're having. Shall try and figure it out and post something soon.

Bruce M. Axtens said...

Let us say for now that my code works for Jacob 1.15-M3 as found on http://sourceforge.net/projects/jacob-project/

If I get it working with subsequent Jacobs ...

Nerd Progre said...

Welcome to the club. And kudos from the other side of the planet. :)

Great minds think alike... what can I say.

I´ve been trying to convince first Sun Microsystems to resurrect its never completed "Project Semplice", and now Oracle.

Oracle, ironically, now owns several pieces of Visual-Basic like languages, first, OO-Basic (OpenOffice Basic) which is built-in in OO.o. And then Oracle had a product dubbed "Oracle PowerObjects" that used a Basic-like syntax!

So, combining the power of the JVM, and an easily-understood language like Basic, by Millions world-wide, is the only natural step.

See, I always say that Java is MUCH MORE than a programming language, it´s a VIRTUAL MACHINE _and_ a software platform.

Unfortunately, some in the Java camp forget about the VM and the software platform, and become zealots of the "Java language religion".

FC

Nerd Progre said...

More on the abandoned Project Semplice:

Three years ago, Sun Microsystems had a project to bring Visual Basic
(VB) programmers to the Java platform, with an IDE that would just compile VB source code directly as Java bytecode, letting VB programmers create 100% Pure Java applications

More info:
http://blogs.sun.com/herbertc/entry/project_semplice_visual_basic_for

With no Java learning curve, this would have brought millions of
hobbyist programmers to the cross-platform, Java bytecode platform.

Unfortunately, the programmers in charge of Project Semplice left Sun.

The intellectual property for Project Semplice likely remains at Sun, and now, Oracle.

Combining the work of Project Semplice AND hiring the Jabaco devs. would be a great way for Oracle to have a "VB.net killer" that compiles Java bytecode.

Make it open source, and BINGO, who needs VB.Net anymore?.

FC

Nerd Progre said...

For the record, here´s what Oracle Basic was (is?)

------
"Oracle kept the developer in mind when choosing the programming
language for Power Objects—Oracle Basic. Oracle Basic is extremely
similar to Visual Basic, with the additions of object extensions and
Structured Query Language (SQL) extensions. BASIC is the most
commonly-used programming language. Any developer familiar with any
version of BASIC will be able to quickly and easily transition to
writing Oracle Basic code in Power Objects. "

http://docs.rinet.ru/Krikun/oun36fi.htm

------

Second: Why Visual Basic (or Oracle Basic, or OpenOffice Basic, or Jabaco)??: because there´s still hundreds of thousands of hobby programmers out there with Visual Basic or Basic-language skills that would instantly become providers of 100% Pure Java applications.

February 2009 survey shows VB6 still alive and kicking
http://www.itjoblog.co.uk/2009/02/visual-basic-6-the-runtime-tha.html

FC