Re: Compiling a single Java class to a plain JavaScript file

2009-01-08 Thread rapodaca

On Jan 8, 8:50 am, "Ian Petersen"  wrote:

> You _might_ be able to get what you want with Ray Cromwell's Exporter.
>  I forget where you can find it, but it's available on the web
> somewhere.  It might be hosted as a Google Code project.  You could
> probably find it by searching this list's history for posts by Ray
> Cromwell that mention "Exporter".  The Exporter basically allows you
> to mark certain classes and interfaces as "exportable".  Exported
> interfaces get wrapped in a bunch of JSNI goo to make it easy for a
> traditional Javascript script to call into the compiled GWT output.

Ian, many thanks. After a quick search, I found these resources:

Announcement of Exporter project:

http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/201528f512c546f3

GWT Exporter Google Code Page:

http://code.google.com/p/gwt-exporter/

At first glance, this looks like exactly what I was after.

> > I thought it was possible to turn off the mangling by setting compiler
> > flags. I've also read about JSNI in this context. Wouldn't one or both
> > of these help?
>
> JSNI can help, and the Exporter automates the drudgery for you.
> Turning off name mangling doesn't help, it just makes it possible for
> a human to read the compiler's output and make associations between
> the compiled code and the Java source that it came from.

Very nice. It looks like the documentation is pretty thin, but the
announcement has enough info to at least get started.

If anyone has any additional info on GWT-Exporter or Exporter-like
packages, I'd be very interested to hear about them.

Thanks,
Rich
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Re: Compiling a single Java class to a plain JavaScript file

2009-01-07 Thread rapodaca



On Jan 7, 12:20 am, Reinier Zwitserloot  wrote:
> What you want can't really be done. Java isn't javascript. Take your
> example just to illustrate the problem here: How would that even
> translate to javascript? Javascript doesn't have classes. It has
> prototype based inheritance. Here are your fundamental problems:

Reinier, thanks for the info. Actually, a class isn't the thing I'm
after. What I really want to create are objects. So I thought it could
translate something like this:


...

...

var hello = new Hello();

hello.talk // returns "hello"

...


What am I missing?

>  1. Javascript's namespacing and object model is so different, that
> GWT internally generates completely different and unwieldy names for
> objects and classes. These names are then mangled to unrecognizable
> shortcodes to reduce the size of the output JS. So, your public void
> hello method is either going to be called: "com.mypackage.Hello::talk
> ()" (yes, including closing parentheses to indicate that this version
> takes no parameters; unlike javascript, in java two methods with the
> same name but different parameter lists are completely separate, in
> javascript you can't do that), or it's going to be called something
> small and effectively random, so something like 'xYq' or some such.
> There's no code to pick a sane name for interaction, so nothing there
> that would even think to generate just a function called "hello".

I thought it was possible to turn off the mangling by setting compiler
flags. I've also read about JSNI in this context. Wouldn't one or both
of these help?

>  2. There's a base set of functions that all GWT projects start out
> with. The GWT compiler assumes this basis is there.

That wouldn't be a problem for me.

>  3. GWT does something called platform targeting. That's why it
> generates a number of JS files - one for each target platform. Out of
> the box, there are already multiple platforms (1 for each major
> supported browser, so there's an Opera, an IE, a Gecko, and a Webkit).
> I'm not entirely sure but I believe the base, talked about in #2, is
> already written specifically for each target browser platform.

Also not a problem.

> If you are in the market to build such a tool, The GWT sources are a
> great place to start, but unless you're willing to dig in for a few
> weeks and do a lot of dev work, I don't think GWT can do what you
> want.

Sounds way above my head. I have to say, though - I'm very surprised
this hasn't been done already. It seems like such an obvious use of
GWT.

> NB: I'm not an expert on the GWT internals so I might have made a few
> mistakes, but I'm fairly sure the above is true. #1 is certainly true,
> and already a big deal for you.
>
> On Jan 7, 7:20 am, rapodaca  wrote:
>
> > On Jan 6, 5:58 pm, Ziyod  wrote:
>
> > > Use GWTCompiler it's part of the com.google.gwt.dev.GWTCompiler
> > > package
> > > Create a gwtCompiler.cmd file and insert this command:
> > > @java -cp "%~dp0\gwt-user.jar;%~dp0\gwt-dev-windows.jar"
> > > com.google.gwt.dev.GWTCompiler %*
>
> > Hello Ziyod,
>
> > Thanks for the information. I'm on Linux, but my best guess for
> > translation is (creating file GWT_INSTALL/gwtCompiler):
>
> > java -cp $HOMEDIR/gwt-user.jar:$HOMEDIR/gwt-dev-linux.jar
> > com.google.gwt.dev.GWTCompiler "$@";
>
> > This is based on the projectCreator script provided in the
> > installation.
>
> > I notice that HOMEDIR is not set so I go:
>
> > $ export HOMEDIR=~/tmp/gwt-linux-1.5.3
>
> > Then I try:
>
> > $ ./gwtCompiler com.example.Test
> > Loading module 'com.example.Test'
> >    [ERROR] Unable to find 'com/example/Test.gwt.xml' on your
> > classpath; could be a typo, or maybe you forgot to include a classpath
> > entry for source?
> > [ERROR] Build failed
>
> > I'm not sure what happened or what the com/example/Test.gwt.xml file
> > refers to. Any ideas of how to generate it and where to save it?
>
> > > Find out more:http://www.screaming-penguin.com/GWTDocs
>
> > That's a good command summary, but unfortunately, I don't see any
> > example usage.
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Re: Compiling a single Java class to a plain JavaScript file

2009-01-06 Thread rapodaca

On Jan 6, 5:58 pm, Ziyod  wrote:
> Use GWTCompiler it's part of the com.google.gwt.dev.GWTCompiler
> package
> Create a gwtCompiler.cmd file and insert this command:
> @java -cp "%~dp0\gwt-user.jar;%~dp0\gwt-dev-windows.jar"
> com.google.gwt.dev.GWTCompiler %*

Hello Ziyod,

Thanks for the information. I'm on Linux, but my best guess for
translation is (creating file GWT_INSTALL/gwtCompiler):

java -cp $HOMEDIR/gwt-user.jar:$HOMEDIR/gwt-dev-linux.jar
com.google.gwt.dev.GWTCompiler "$@";

This is based on the projectCreator script provided in the
installation.

I notice that HOMEDIR is not set so I go:

$ export HOMEDIR=~/tmp/gwt-linux-1.5.3

Then I try:

$ ./gwtCompiler com.example.Test
Loading module 'com.example.Test'
   [ERROR] Unable to find 'com/example/Test.gwt.xml' on your
classpath; could be a typo, or maybe you forgot to include a classpath
entry for source?
[ERROR] Build failed

I'm not sure what happened or what the com/example/Test.gwt.xml file
refers to. Any ideas of how to generate it and where to save it?

> Find out more:http://www.screaming-penguin.com/GWTDocs

That's a good command summary, but unfortunately, I don't see any
example usage.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Compiling a single Java class to a plain JavaScript file

2009-01-06 Thread rapodaca

Greetings,

Is it possible to use GWT to convert a single Java class to a
JavaScript file that can be used within a browser? If so, how?

More specifically, if I have a file called Hello.java containing:

public class Hello
{
  public String talk()
  {
return "hello";
  }
}

how can I use GWT to convert it into a single file called hello.js
that could be used to instantiate a Hello object and call it's talk
method?

Almost all of the documentation on GWT I've been able to find deals
with creating a Web site. I'd like to do something much simpler - just
convert my Java class to a Javascript class-like structure that can
instantiate an object and invoke its methods.

This seems like something that should be trivial, but I've had no luck
finding out how to get it done.

Many thanks,
Rich

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---