• Post Reply Bookmark Topic Watch Topic
  • New Topic

Setting the menu bar  RSS feed

 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello. I have an application that requires a menu bar.
I have put the code

in the constructor of the class, and when I run it, it works.
However, I am launching the above class (which has it's own main method)
from a front end application using Runtime.exec().
When the application is launched from the front end app, the menu bar is nowhere to be found?? Where did it go??
Does it matter that the front end app has a JMenuBar as well. I didn't think that should make any difference, but maybe I'm wrong.
Thanks for any help!!
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So let me see if I understand this correctly. If you run your program like:
java myClass
But when you do it from inside another java app like:
Runtime.exec("java myClass");
It doesn't show the menu bar?
I can't think of any reason why this would happen right off the top of my head. Unless there is some classpath issue but that would mean your MenuBar is some arbitrary package that isn't the same as the rest of your app, which probably isn't the case.....
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is absolutely correct.
Weird huh?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just tested this out and I'm getting both menu bars. Test the code out on your machine and see if it works too. You'll have to modify the paths used in the exec to get it to work. I'm thinking there's something else going on... like maybe the default classpath points to an old version of the class, before it had a menubar...

 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I must be doing something wrong. I tried modifying the exec() path to mine, and I can't seem to get the InsideApp to launch.
My file structure looks like this:
C:
Eclipse
Workspace
Test Project
bin
test
menu
InsideApp.class
This is what I have in my exec() method:

I must be overlooking something, do you see it?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The spaces in the classpath can screw all kinds of things up. ( *CURSE YOU BILL GATES!!!* ) Try moving your class to a different folder (or renaming it without spaces) and see if it works then.
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yippee! I got your code to run, and the menu bar on the
launched app showed up.
So, what is my next step. What do I need to be looking for?
By the way, I don't know if it matters, but I am using Eclipse to build my java programs, if that changes anything.
Thanks again for helping!
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just thought I'd let you know, I've got this issue resolved.
When you had said that the classpath was probably looking at an old version of the .class file if your code worked, I was confused, because I had my classpath set directly to where I wanted it to go.
HOWEVER.....
At the very beginning of my classpath, (which is someplace I wasn't looking) I had it pointing to a directory on our server where I keep a backup of my java apps.
So I changed the classpath to look at the directory in eclipse before it looked at the server, and GUESS WHAT??
It worked.
Once again, THANK YOU VERY MUCH for all of your help.
Here's to you!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!