hellow world label problem? [message #450728] |
Thu, 17 February 2005 03:47 |
Eclipse User |
|
|
|
Originally posted by: caiusv.plumtree.com
I seem to be making some obvious mistake here, but can't figure out what.
I have code here that will display the hello world label when the class is
run from inside Eclipse, but as a standalone app compiled with swt 3.0.1
the label does not display.
I'm at a loss to understand why.
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Button;
public class HelloWorld {
public static void main (String [] args) {
Display display = new Display ();
final Shell shell = new Shell(display);
RowLayout layout = new RowLayout();
layout.justify = true;
layout.pack = true;
shell.setLayout(layout);
shell.setText("Hello, World!");
Label label = new Label(shell, SWT.CENTER);
label.setText("Hello, World!");
shell.pack();
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}
|
|
|
|
Re: hellow world label problem? [message #450871 is a reply to message #450728] |
Fri, 18 February 2005 21:31 |
Eclipse User |
|
|
|
Originally posted by: johns.atwork.comhem.se
Runs fine for me. JRE 1.4.2. on windows XP. Built a jar file and ran it - no problem.
/John
caius van nouhuys wrote:
> I seem to be making some obvious mistake here, but can't figure out
> what. I have code here that will display the hello world label when the
> class is run from inside Eclipse, but as a standalone app compiled with
> swt 3.0.1 the label does not display.
>
> I'm at a loss to understand why.
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.layout.RowLayout;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Shell;
> import org.eclipse.swt.widgets.Label;
> import org.eclipse.swt.widgets.Button;
>
> public class HelloWorld {
> public static void main (String [] args) {
> Display display = new Display ();
> final Shell shell = new Shell(display);
> RowLayout layout = new RowLayout();
> layout.justify = true;
> layout.pack = true;
> shell.setLayout(layout);
> shell.setText("Hello, World!");
> Label label = new Label(shell, SWT.CENTER);
> label.setText("Hello, World!");
> shell.pack();
> shell.open ();
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }
> }
>
|
|
|
Re: hellow world label problem? [message #450872 is a reply to message #450871] |
Fri, 18 February 2005 22:08 |
Eclipse User |
|
|
|
Originally posted by: caiusv.plumtree.com
I'm using Windows Server 2003. I've got eclipse 3.0, I've tried both java
1.4.2 and 1.4.1. I built and ran the code fine on macosx. I figured there
must be something wrong with my environment on the Windows machine, but
I've gotten to the point where I've removed all environment issues and
specify everything on the command line to limit variables.
I've got swt.jar and the dll in a dir called lib and the code in the
directory above where I can run this:
javac -classpath lib/swt.jar HelloWorld.java
java -classpath lib/swt.jar -Djava.library.path=lib HelloWorld
But still, no labels show up.
John S wrote:
> Runs fine for me. JRE 1.4.2. on windows XP. Built a jar file and ran it - no
problem.
> /John
> caius van nouhuys wrote:
>> I seem to be making some obvious mistake here, but can't figure out
>> what. I have code here that will display the hello world label when the
>> class is run from inside Eclipse, but as a standalone app compiled with
>> swt 3.0.1 the label does not display.
>>
>> I'm at a loss to understand why.
>>
>> import org.eclipse.swt.SWT;
>> import org.eclipse.swt.layout.RowLayout;
>> import org.eclipse.swt.widgets.Display;
>> import org.eclipse.swt.widgets.Shell;
>> import org.eclipse.swt.widgets.Label;
>> import org.eclipse.swt.widgets.Button;
>>
>> public class HelloWorld {
>> public static void main (String [] args) {
>> Display display = new Display ();
>> final Shell shell = new Shell(display);
>> RowLayout layout = new RowLayout();
>> layout.justify = true;
>> layout.pack = true;
>> shell.setLayout(layout);
>> shell.setText("Hello, World!");
>> Label label = new Label(shell, SWT.CENTER);
>> label.setText("Hello, World!");
>> shell.pack();
>> shell.open ();
>> while (!shell.isDisposed ()) {
>> if (!display.readAndDispatch ()) display.sleep ();
>> }
>> display.dispose ();
>> }
>> }
>>
|
|
|
Re: hellow world label problem? [message #450873 is a reply to message #450872] |
Fri, 18 February 2005 23:10 |
Veronika Irvine Messages: 1272 Registered: July 2009 |
Senior Member |
|
|
Do you get anything? Does the shell open?
Avoid spaces in the folder names - they make the command harder to get
right.
You can get the exact command used by eclipse as follows:
Run the application in Eclipse. Go to the Debug perspective
Select the first sub node in the Debug View (called something like
D:\jdk1.4.2\bin\java.exe)
With the right mouse button open the context menu and select Properties.
The Process Information will show you the command line.
For example, I get:
D:\Eclipse\vm\jdk1.4.2_03\bin\javaw.exe -Djava.library.path=D:\Eclipse\workspace\org.eclipse.swt.win 32\os\win32\x86
-classpath
D:\Eclipse\workspace\Test;D:\Eclipse\Eclipse3.1\eclipse\plug ins\org.eclipse.swt.win32_3.1.0\ws\win32\swt.jar
Main
"caius van nouhuys" <caiusv@plumtree.com> wrote in message
news:cv5p01$mud$1@www.eclipse.org...
> I'm using Windows Server 2003. I've got eclipse 3.0, I've tried both java
> 1.4.2 and 1.4.1. I built and ran the code fine on macosx. I figured there
> must be something wrong with my environment on the Windows machine, but
> I've gotten to the point where I've removed all environment issues and
> specify everything on the command line to limit variables.
> I've got swt.jar and the dll in a dir called lib and the code in the
> directory above where I can run this:
>
> javac -classpath lib/swt.jar HelloWorld.java
>
> java -classpath lib/swt.jar -Djava.library.path=lib HelloWorld
>
> But still, no labels show up.
>
> John S wrote:
>
>> Runs fine for me. JRE 1.4.2. on windows XP. Built a jar file and ran it -
>> no
> problem.
>
>> /John
>
>> caius van nouhuys wrote:
>>> I seem to be making some obvious mistake here, but can't figure out
>>> what. I have code here that will display the hello world label when the
>>> class is run from inside Eclipse, but as a standalone app compiled with
>>> swt 3.0.1 the label does not display.
>>>
>>> I'm at a loss to understand why.
>>>
>>> import org.eclipse.swt.SWT;
>>> import org.eclipse.swt.layout.RowLayout;
>>> import org.eclipse.swt.widgets.Display;
>>> import org.eclipse.swt.widgets.Shell;
>>> import org.eclipse.swt.widgets.Label;
>>> import org.eclipse.swt.widgets.Button;
>>>
>>> public class HelloWorld {
>>> public static void main (String [] args) {
>>> Display display = new Display ();
>>> final Shell shell = new Shell(display);
>>> RowLayout layout = new RowLayout();
>>> layout.justify = true;
>>> layout.pack = true;
>>> shell.setLayout(layout);
>>> shell.setText("Hello, World!");
>>> Label label = new Label(shell, SWT.CENTER);
>>> label.setText("Hello, World!");
>>> shell.pack();
>>> shell.open ();
>>> while (!shell.isDisposed ()) {
>>> if (!display.readAndDispatch ()) display.sleep ();
>>> }
>>> display.dispose ();
>>> }
>>> }
>>>
>
>
|
|
|
Re: hellow world label problem? [message #450876 is a reply to message #450873] |
Sat, 19 February 2005 01:45 |
Eclipse User |
|
|
|
Originally posted by: caiusv.plumtree.com
Thanks Veronika that was a helpful suggestion. After taking a look at what
Eclipse used as a command line I found that using 'javaw' allows my
HelloWorld program to work while using 'java' to execute it failed.
??
Not sure how you explain this, but with this command line:
C:\tmp\swttest>javaw -Djava.library.path="lib" -classpath ./;lib/swt.jar
HelloWorld
the window pops up with the label visible. However, with this command line
C:\tmp\swttest>java -Djava.library.path="lib" -classpath ./;lib/swt.jar
HelloWorld
the window pops up, but there is no label visible.
Veronika Irvine wrote:
> Do you get anything? Does the shell open?
> Avoid spaces in the folder names - they make the command harder to get
> right.
> You can get the exact command used by eclipse as follows:
> Run the application in Eclipse. Go to the Debug perspective
> Select the first sub node in the Debug View (called something like
> D:jdk1.4.2binjava.exe)
> With the right mouse button open the context menu and select Properties.
> The Process Information will show you the command line.
> For example, I get:
> D:Eclipsevmjdk1.4.2_03binjavaw.exe
-Djava.library.path=D:Eclipseworkspaceorg.eclipse.swt.win32o swin32x86
> -classpath
>
D:EclipseworkspaceTest;D:EclipseEclipse3.1eclipsepluginsorg. eclipse.swt.win32_3.1.0wswin32swt.jar
> Main
> "caius van nouhuys" <caiusv@plumtree.com> wrote in message
> news:cv5p01$mud$1@www.eclipse.org...
>> I'm using Windows Server 2003. I've got eclipse 3.0, I've tried both java
>> 1.4.2 and 1.4.1. I built and ran the code fine on macosx. I figured there
>> must be something wrong with my environment on the Windows machine, but
>> I've gotten to the point where I've removed all environment issues and
>> specify everything on the command line to limit variables.
>> I've got swt.jar and the dll in a dir called lib and the code in the
>> directory above where I can run this:
>>
>> javac -classpath lib/swt.jar HelloWorld.java
>>
>> java -classpath lib/swt.jar -Djava.library.path=lib HelloWorld
>>
>> But still, no labels show up.
>>
>> John S wrote:
>>
>>> Runs fine for me. JRE 1.4.2. on windows XP. Built a jar file and ran it -
>>> no
>> problem.
>>
>>> /John
>>
>>> caius van nouhuys wrote:
>>>> I seem to be making some obvious mistake here, but can't figure out
>>>> what. I have code here that will display the hello world label when the
>>>> class is run from inside Eclipse, but as a standalone app compiled with
>>>> swt 3.0.1 the label does not display.
>>>>
>>>> I'm at a loss to understand why.
>>>>
>>>> import org.eclipse.swt.SWT;
>>>> import org.eclipse.swt.layout.RowLayout;
>>>> import org.eclipse.swt.widgets.Display;
>>>> import org.eclipse.swt.widgets.Shell;
>>>> import org.eclipse.swt.widgets.Label;
>>>> import org.eclipse.swt.widgets.Button;
>>>>
>>>> public class HelloWorld {
>>>> public static void main (String [] args) {
>>>> Display display = new Display ();
>>>> final Shell shell = new Shell(display);
>>>> RowLayout layout = new RowLayout();
>>>> layout.justify = true;
>>>> layout.pack = true;
>>>> shell.setLayout(layout);
>>>> shell.setText("Hello, World!");
>>>> Label label = new Label(shell, SWT.CENTER);
>>>> label.setText("Hello, World!");
>>>> shell.pack();
>>>> shell.open ();
>>>> while (!shell.isDisposed ()) {
>>>> if (!display.readAndDispatch ()) display.sleep ();
>>>> }
>>>> display.dispose ();
>>>> }
>>>> }
>>>>
>>
>>
|
|
|
Powered by
FUDForum. Page generated in 0.03388 seconds