Skip to search.

Breaking News Visit Yahoo! News for the latest.

×Close this window

SubEthaEdit

The Yahoo! Groups Product Blog

Check it out!

Group Information

  • Members: 249
  • Category: Software
  • Founded: Dec 19, 2005
  • Language: English
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Messages

Advanced
Messages Help
Running Java   Topic List   < Prev Topic  |  Next Topic >
Summarize Messages Sort by Date  
#162 From: "Peter K. Johnson" <peter.johnson@...>
Date: Thu Jan 31, 2008 4:56 pm
Subject: Running Java
petermankato
Send Email Send Email
 
When I use the Compile and Run button on the menu bar SubEthaEdit compiles my classes okay but gives me an error that it can’t find a class that is external to the class containing my main( ). Both the class with main( ) and the class that is called from main( ) are in the same folder.

If I go into Terminal window and run the program from the command prompt it works perfectly so I know my code is correct. (It’s also a very simple test program.)

Is there a script or setting that I can change to get the Compile and Run button to work properly?

Peter Johnson

#163 From: "michael_j_barber" <michael_j_barber@...>
Date: Mon Feb 4, 2008 9:59 am
Subject: Re: Running Java
michael_j_ba...
Send Email Send Email
 
I've taken a look at the Java mode scripts, and I think I know what the problem
is.
However, I don't really do any Java programming, so I can't be completely
certain. I can tell
you what to try in order to get things clear, though, and then maybe a solution
will
become apparent.

Here's my thinking. You're seeing an error at compile time, not at run time. The
"Compile"
and "Compile and run" scripts do not call the compiler in the same way. Both use
"do shell
script" to call out to the shell, but not using the same command string.

"Compile" switches to the directory containing the front SEE document, which is
your
main(). It then compiles the document using javac. You don't really say, but I'm
guessing
that "Compile" works OK?

"Compile and run" doesn't work that way. It just calls javac to do the
compilation. That's
equivalent to something like:
# cd /
# javac -encoding UTF8 path/to/your/mainfile.java
Would that give the error you're seeing from "Compile and run"?


--- In SubEthaEdit@yahoogroups.com, "Peter K. Johnson" <peter.johnson@...>
wrote:
>
> When I use the Compile and Run button on the menu bar SubEthaEdit compiles
> my classes okay but gives me an error that it canıt find a class that is
> external to the class containing my main( ). Both the class with main( ) and
> the class that is called from main( ) are in the same folder.
>
> If I go into Terminal window and run the program from the command prompt it
> works perfectly so I know my code is correct. (Itıs also a very simple test
> program.)
>
> Is there a script or setting that I can change to get the Compile and Run
> button to work properly?
>
> Peter Johnson
>






#164 From: "petermankato" <peter.johnson@...>
Date: Mon Feb 4, 2008 2:27 pm
Subject: Re: Running Java
petermankato
Send Email Send Email
 
Michael,
Thanks for the details. The problem seems to be when Java is called to
run the compiled program. I did a quick video (using Jing) to show
what happens: http://screencast.com/t/BJh2c1cSu

I know that this is not good form, using a class directly
(Keyboard.readDouble( )) but this is the second program my students
write for Java I and I build off of this experience as the semester
unfolds.

Thanks for your help in figuring out how to change the script so I can
use the Compile and Run button.

Peter

--- In SubEthaEdit@yahoogroups.com, "michael_j_barber"
<michael_j_barber@...> wrote:
>
> I've taken a look at the Java mode scripts, and I think I know what
the problem is.
> However, I don't really do any Java programming, so I can't be
completely certain. I can tell
> you what to try in order to get things clear, though, and then maybe
a solution will
> become apparent.
>
> Here's my thinking. You're seeing an error at compile time, not at
run time. The "Compile"
> and "Compile and run" scripts do not call the compiler in the same
way. Both use "do shell
> script" to call out to the shell, but not using the same command
string.
>
> "Compile" switches to the directory containing the front SEE
document, which is your
> main(). It then compiles the document using javac. You don't really
say, but I'm guessing
> that "Compile" works OK?
>
> "Compile and run" doesn't work that way. It just calls javac to do
the compilation. That's
> equivalent to something like:
> # cd /
> # javac -encoding UTF8 path/to/your/mainfile.java
> Would that give the error you're seeing from "Compile and run"?
>
>
> --- In SubEthaEdit@yahoogroups.com, "Peter K. Johnson"
<peter.johnson@> wrote:
> >
> > When I use the Compile and Run button on the menu bar SubEthaEdit
compiles
> > my classes okay but gives me an error that it canıt find a class
that is
> > external to the class containing my main( ). Both the class with
main( ) and
> > the class that is called from main( ) are in the same folder.
> >
> > If I go into Terminal window and run the program from the command
prompt it
> > works perfectly so I know my code is correct. (Itıs also a very
simple test
> > program.)
> >
> > Is there a script or setting that I can change to get the Compile
and Run
> > button to work properly?
> >
> > Peter Johnson
> >
>





#165 From: "michael_j_barber" <michael_j_barber@...>
Date: Mon Feb 4, 2008 7:12 pm
Subject: Re: Running Java
michael_j_ba...
Send Email Send Email
 
After watching your screencast, I think it might be a good idea to extract out
the core of
the Compile and Run script, and see if we can't better isolate where it goes
wrong.
However, even with that, it might not be feasible to get things working as you
hope; I'll
comment on that after sketching out the structure of what the Compile and Run
AppleScript is doing.

All that really happens is that two shell commands are constructed, and passed
to the shell
using "do shell script". Based on the paths in your screencast, the first shell
command is:
javac -encoding UTF8
'/Users/peterj/classJava1/dakeDavid/prjDataType/DebugMe.java
That would be run, in effect, from the root directory.

The second shell command is:
cd "/Users/peterj/classJava1/dakeDavid/prjDataType/" && java 'DebugMe'
Again, it would be run from root, but it of course makes no difference in this
case.

Those might well be enough for you to see where the error comes from. If not,
you could
try each of those from the Terminal (remembering to "cd /" before each). If it
still works,
then it must be a difference between the shell environment and the environment
provided
by "do shell script". To experiment with that, pulling the core of the
AppleScript into a
separate AppleScript is useful, since then we can run it from Script Editor and
put up alerts
after each of the shell commands. Here's an appropriate AppleScript (more
discussion
follows):

-- begin script
-- file path components
set parentPath to "/Users/peterj/classJava1/dakeDavid/prjDataType/"
set fileName to "DebugMe.java"
set javaAppName to "DebugMe"

-- reconstruct the file path that SubEthaEdit would normally provide
set filepath to parentPath & fileName

-- build compile and run strings
set javacString to "javac -encoding UTF8 " & quoted form of filepath
set execJavaString to "cd \"" & parentPath & "\" && " & "java " & quoted form of
javaAppName

-- compile and show result
set compileResult to do shell script javacString
display alert "Compile succeeded" message ("Shell script: " & return &
javacString & return
& return & "Returned:" & return & compileResult)

-- run and show result
set runResult to do shell script execJavaString
display alert "Run succeeded" message ("Shell script: " & return &
execJavaString & return &
return & "Returned:" & return & runResult)

-- end of script

With that, it should be feasible to experiment and identify where the problem
occurs.
Unfortunately, I'm not sure that Compile and Run is going to do what you want,
even with
changes. From the screencast, the DebugMe program seems to depend on interaction
with
the user. I don't think that's possible with "do shell script".

All is not lost, however! There is another approach, which might be suitable.
The Terminal
is scriptable, and has a "do script" action. You could just construct a string
containing a
shell command along the lines of:
cd "/Users/peterj/classJava1/dakeDavid/prjDataType/" && javac -encoding UTF8
'DebugMe.java && java 'DebugMe'
All that could be wrapped up in a new shell script, and added to a local Java
mode for your
class.

At this point, I'm not sure what else to suggest. I'm willing to help further,
if I can, but will
need some more information.

--- In SubEthaEdit@yahoogroups.com, "petermankato" <peter.johnson@...> wrote:
>
> Michael,
> Thanks for the details. The problem seems to be when Java is called to
> run the compiled program. I did a quick video (using Jing) to show
> what happens: http://screencast.com/t/BJh2c1cSu
>
> I know that this is not good form, using a class directly
> (Keyboard.readDouble( )) but this is the second program my students
> write for Java I and I build off of this experience as the semester
> unfolds.
>
> Thanks for your help in figuring out how to change the script so I can
> use the Compile and Run button.
>
> Peter
>
> --- In SubEthaEdit@yahoogroups.com, "michael_j_barber"
> <michael_j_barber@> wrote:
> >
> > I've taken a look at the Java mode scripts, and I think I know what
> the problem is.
> > However, I don't really do any Java programming, so I can't be
> completely certain. I can tell
> > you what to try in order to get things clear, though, and then maybe
> a solution will
> > become apparent.
> >
> > Here's my thinking. You're seeing an error at compile time, not at
> run time. The "Compile"
> > and "Compile and run" scripts do not call the compiler in the same
> way. Both use "do shell
> > script" to call out to the shell, but not using the same command
> string.
> >
> > "Compile" switches to the directory containing the front SEE
> document, which is your
> > main(). It then compiles the document using javac. You don't really
> say, but I'm guessing
> > that "Compile" works OK?
> >
> > "Compile and run" doesn't work that way. It just calls javac to do
> the compilation. That's
> > equivalent to something like:
> > # cd /
> > # javac -encoding UTF8 path/to/your/mainfile.java
> > Would that give the error you're seeing from "Compile and run"?
> >
> >
> > --- In SubEthaEdit@yahoogroups.com, "Peter K. Johnson"
> <peter.johnson@> wrote:
> > >
> > > When I use the Compile and Run button on the menu bar SubEthaEdit
> compiles
> > > my classes okay but gives me an error that it canıt find a class
> that is
> > > external to the class containing my main( ). Both the class with
> main( ) and
> > > the class that is called from main( ) are in the same folder.
> > >
> > > If I go into Terminal window and run the program from the command
> prompt it
> > > works perfectly so I know my code is correct. (Itıs also a very
> simple test
> > > program.)
> > >
> > > Is there a script or setting that I can change to get the Compile
> and Run
> > > button to work properly?
> > >
> > > Peter Johnson
> > >
> >
>






 
Add to My Yahoo!      XML What's This?

Copyright İ 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help