fork download
  1. package com.m_v.test;
  2.  
  3. import java.io.File;
  4. import java.net.URL;
  5. import java.util.concurrent.TimeUnit;
  6.  
  7. import org.eclipse.swt.*;
  8. import org.eclipse.swt.graphics.Point;
  9. import org.eclipse.swt.layout.FillLayout;
  10. import org.eclipse.swt.widgets.*;
  11.  
  12.  
  13. public class SecondVM {
  14.  
  15. public static void main(String[] args) {
  16. if ( System.getenv("SWT_GTK3") == null
  17. || System.getenv("LIBOVERLAY_SCROLLBAR") == null )
  18. {
  19. URL classResource = SecondVM.class.getResource("SecondVM.class");
  20. boolean fromJar = classResource.getProtocol().equals("rsrc");
  21.  
  22. String exePath = ClassLoader.getSystemClassLoader().getResource(".").getPath();
  23. exePath = new File(exePath).getAbsolutePath().replaceFirst("\\.$", "").replaceFirst("bin$", "");
  24. if (!exePath.endsWith(System.getProperty("file.separator")))
  25. exePath += System.getProperty("file.separator");
  26.  
  27. String[] script = {
  28. "/bin/bash", "-c",
  29. "export SWT_GTK3=0; "
  30. + "export LIBOVERLAY_SCROLLBAR=0; "
  31. + (fromJar?
  32. "java -jar " + exePath + "SecondVM.jar" : // if runs from jar
  33. "java -cp ./bin/:../ExtLibs/swt_linux64/swt.jar " // if runs from under Eclipse or somewhat alike
  34. + "com.m_v.test.SecondVM")
  35. };
  36.  
  37. try {
  38. Process p = new ProcessBuilder(script).start();
  39.  
  40. // When jar is run from a bash script, it kills the second VM when exits.
  41. // Let it has some time to take a breath
  42. p.waitFor(12, TimeUnit.HOURS);
  43. } catch (Exception e) { e.printStackTrace(); }
  44. System.exit(0);
  45. }
  46.  
  47.  
  48. Display display = Display.getDefault();
  49. Shell shell = new Shell(display);
  50. shell.setText("test");
  51. shell.setLayout(new FillLayout());
  52.  
  53. Text text = new Text(shell, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL );
  54. text.setText( // To fill the text to make the scrollbar appear
  55. "1111111111\n2222222222\n3333333333\n4444444444\n5555555555\n6666666666\n7777777777\n8888888888\n9999999999\n0000000000\n"
  56. + "1111111111\n2222222222\n3333333333\n4444444444\n5555555555\n6666666666\n7777777777\n8888888888\n9999999999\n0000000000\n"
  57. + "1111111111\n2222222222\n3333333333\n4444444444\n5555555555\n6666666666\n7777777777\n8888888888\n9999999999\n0000000000\n"
  58. );
  59.  
  60. shell.setSize(new Point(300,200));
  61. shell.open();
  62.  
  63. while (!shell.isDisposed())
  64. if (!display.readAndDispatch())
  65. display.sleep();
  66.  
  67. }
  68. }
  69.  
  70.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:13: error: class SecondVM is public, should be declared in a file named SecondVM.java
public class SecondVM {
       ^
Main.java:7: error: package org.eclipse.swt does not exist
import org.eclipse.swt.*;
^
Main.java:8: error: package org.eclipse.swt.graphics does not exist
import org.eclipse.swt.graphics.Point;
                               ^
Main.java:9: error: package org.eclipse.swt.layout does not exist
import org.eclipse.swt.layout.FillLayout;
                             ^
Main.java:10: error: package org.eclipse.swt.widgets does not exist
import org.eclipse.swt.widgets.*;
^
Main.java:48: error: cannot find symbol
	Display display = Display.getDefault();
	^
  symbol:   class Display
  location: class SecondVM
Main.java:48: error: cannot find symbol
	Display display = Display.getDefault();
	                  ^
  symbol:   variable Display
  location: class SecondVM
Main.java:49: error: cannot find symbol
	Shell shell = new Shell(display);
	^
  symbol:   class Shell
  location: class SecondVM
Main.java:49: error: cannot find symbol
	Shell shell = new Shell(display);
	                  ^
  symbol:   class Shell
  location: class SecondVM
Main.java:51: error: cannot find symbol
	shell.setLayout(new FillLayout());
	                    ^
  symbol:   class FillLayout
  location: class SecondVM
Main.java:53: error: cannot find symbol
	Text text = new Text(shell, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL );
	^
  symbol:   class Text
  location: class SecondVM
Main.java:53: error: cannot find symbol
	Text text = new Text(shell, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL );
	                ^
  symbol:   class Text
  location: class SecondVM
Main.java:53: error: cannot find symbol
	Text text = new Text(shell, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL );
	                            ^
  symbol:   variable SWT
  location: class SecondVM
Main.java:53: error: cannot find symbol
	Text text = new Text(shell, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL );
	                                        ^
  symbol:   variable SWT
  location: class SecondVM
Main.java:53: error: cannot find symbol
	Text text = new Text(shell, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL );
	                                                     ^
  symbol:   variable SWT
  location: class SecondVM
Main.java:60: error: cannot find symbol
    shell.setSize(new Point(300,200));
                      ^
  symbol:   class Point
  location: class SecondVM
16 errors
stdout
Standard output is empty