Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Trouble running code on Windows(Can't run code developed on Linux on Windows b/c missing dependencies)
Trouble running code on Windows [message #870853] |
Wed, 09 May 2012 23:22 |
Jesse Osiecki Messages: 7 Registered: May 2012 |
Junior Member |
|
|
I have a bit of a strange issue. I am developing an application using the WindowBuilder and associated libraries. The program works great on my 32-bit Linux box that I have been developing on. However I have two issues.
1) When running the jar on a 64-bit machine, it fails, which makes sense because I packaged the 32-bit libraries in the jar. If someone knows how to make the jar dual architecture, help would be greatly appreciated.
2) More importantly (as my client is chiefly 32-bit Windows XP as most of the world is) I can't run it on Windows. I actually moved the project over to a windows box, set up the WindowBuilder libraries in Eclipse, and recompiled, and it did work. However when I try to use my jar created in Linux, it fails with a message that I will attach (something about needing swt_gtk libraries). Now I'm somewhat new with java, but isn't the goal interoperability? I just find it strange that WindowBuilder seems to be using platform specific code. That being said, any ways around this (ways to make the program work on multiple operating systems) would be fantastic.
Sincerely,
Jesse
Also, I had posted this in the WindowBuilder section, but they sent me here. So my apologies for the duplicates.
|
|
| | | | |
Re: Trouble running code on Windows [message #871578 is a reply to message #871311] |
Mon, 14 May 2012 13:04 |
Andi Thomas Messages: 38 Registered: July 2009 |
Member |
|
|
Attached are the build.xml and the main starting class
I've modified them slightly from the ones I actually use to remove any
possible reference to stuff I do for work, so there might be some typos
in there.
It should all be fairly obvious, let me know if you have questions.
In the build I'm currently only packaging for Win32/64. Its obvious and
easy to expand to all SWT platforms.
On 5/11/12 5:26 PM, Jesse Osiecki wrote:
> I'm messing with that code given in the error trying to get it to
> chainload my program. Two questions.
>
> 1) What does your ant build script look like?
>
> 2)I have completely forgotten and will probably ask later 8)
package com.andi;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Properties;
public class Main {
private static final String LAUNCH_CLASS = "com.andi.TheRealMainClass";
public static void main(final String[] args) {
final String osArch = System.getProperty("os.arch");
final String osName = System.getProperty("os.name").toUpperCase();
final boolean is32bit = !osArch.contains("64");
final boolean isWindows = osName.contains("WINDOWS");
final boolean isLinux = osName.contains("LINUX") || osName.contains("NIX");
final boolean isMac = osName.contains("MAC");
String path = "";
if (isWindows)
path = "win";
else if (isLinux)
path = "gtk";
else if (isMac)
path = "mac";
if (is32bit)
path = path + "32";
else
path = path + "64";
System.out.println("Selected SWT classpath platform: " + path);
final ClassLoader parent = Main.class.getClassLoader();
final ArrayList<URL> urls = new ArrayList<URL>();
try {
final InputStream stream = parent.getResourceAsStream("libjars.properties");
final Properties properties = new Properties();
properties.load(stream);
stream.close();
String libs = (String) properties.get("contents");
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + aLib + "!/"));
}
libs = (String) properties.get("contents." + path);
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + path + "/" + aLib + "!/"));
}
} catch (final Throwable e1) {
}
try {
if (urls.size() > 0) {
final Method m1 = parent.getClass().getDeclaredMethod("addURL", URL.class);
m1.setAccessible(true);
for (final URL url : urls) {
m1.invoke(parent, url);
}
for (final URL url : ((URLClassLoader) parent).getURLs()) {
System.out.println(url);
}
}
final Class<?> class1 = parent.loadClass(LAUNCH_CLASS);
final Method method = class1.getMethod("launch", String[].class);
final Object[] methodArgs = new Object[] { args };
method.invoke(null, methodArgs);
} catch (final Throwable e) {
e.printStackTrace();
}
}
}
-
Attachment: build.xml
(Size: 2.23KB, Downloaded 150 times) -
Attachment: main.java
(Size: 2.24KB, Downloaded 173 times)
|
|
|
Re: Trouble running code on Windows [message #871580 is a reply to message #871311] |
Mon, 14 May 2012 13:04 |
Andi Thomas Messages: 38 Registered: July 2009 |
Member |
|
|
Attached are the build.xml and the main starting class
I've modified them slightly from the ones I actually use to remove any
possible reference to stuff I do for work, so there might be some typos
in there.
It should all be fairly obvious, let me know if you have questions.
In the build I'm currently only packaging for Win32/64. Its obvious and
easy to expand to all SWT platforms.
On 5/11/12 5:26 PM, Jesse Osiecki wrote:
> I'm messing with that code given in the error trying to get it to
> chainload my program. Two questions.
>
> 1) What does your ant build script look like?
>
> 2)I have completely forgotten and will probably ask later 8)
package com.andi;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Properties;
public class Main {
private static final String LAUNCH_CLASS = "com.andi.TheRealMainClass";
public static void main(final String[] args) {
final String osArch = System.getProperty("os.arch");
final String osName = System.getProperty("os.name").toUpperCase();
final boolean is32bit = !osArch.contains("64");
final boolean isWindows = osName.contains("WINDOWS");
final boolean isLinux = osName.contains("LINUX") || osName.contains("NIX");
final boolean isMac = osName.contains("MAC");
String path = "";
if (isWindows)
path = "win";
else if (isLinux)
path = "gtk";
else if (isMac)
path = "mac";
if (is32bit)
path = path + "32";
else
path = path + "64";
System.out.println("Selected SWT classpath platform: " + path);
final ClassLoader parent = Main.class.getClassLoader();
final ArrayList<URL> urls = new ArrayList<URL>();
try {
final InputStream stream = parent.getResourceAsStream("libjars.properties");
final Properties properties = new Properties();
properties.load(stream);
stream.close();
String libs = (String) properties.get("contents");
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + aLib + "!/"));
}
libs = (String) properties.get("contents." + path);
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + path + "/" + aLib + "!/"));
}
} catch (final Throwable e1) {
}
try {
if (urls.size() > 0) {
final Method m1 = parent.getClass().getDeclaredMethod("addURL", URL.class);
m1.setAccessible(true);
for (final URL url : urls) {
m1.invoke(parent, url);
}
for (final URL url : ((URLClassLoader) parent).getURLs()) {
System.out.println(url);
}
}
final Class<?> class1 = parent.loadClass(LAUNCH_CLASS);
final Method method = class1.getMethod("launch", String[].class);
final Object[] methodArgs = new Object[] { args };
method.invoke(null, methodArgs);
} catch (final Throwable e) {
e.printStackTrace();
}
}
}
-
Attachment: build.xml
(Size: 2.23KB, Downloaded 220 times) -
Attachment: main.java
(Size: 2.24KB, Downloaded 153 times)
|
|
|
Re: Trouble running code on Windows [message #871583 is a reply to message #871311] |
Mon, 14 May 2012 13:04 |
Andi Thomas Messages: 38 Registered: July 2009 |
Member |
|
|
Attached are the build.xml and the main starting class
I've modified them slightly from the ones I actually use to remove any
possible reference to stuff I do for work, so there might be some typos
in there.
It should all be fairly obvious, let me know if you have questions.
In the build I'm currently only packaging for Win32/64. Its obvious and
easy to expand to all SWT platforms.
On 5/11/12 5:26 PM, Jesse Osiecki wrote:
> I'm messing with that code given in the error trying to get it to
> chainload my program. Two questions.
>
> 1) What does your ant build script look like?
>
> 2)I have completely forgotten and will probably ask later 8)
package com.andi;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Properties;
public class Main {
private static final String LAUNCH_CLASS = "com.andi.TheRealMainClass";
public static void main(final String[] args) {
final String osArch = System.getProperty("os.arch");
final String osName = System.getProperty("os.name").toUpperCase();
final boolean is32bit = !osArch.contains("64");
final boolean isWindows = osName.contains("WINDOWS");
final boolean isLinux = osName.contains("LINUX") || osName.contains("NIX");
final boolean isMac = osName.contains("MAC");
String path = "";
if (isWindows)
path = "win";
else if (isLinux)
path = "gtk";
else if (isMac)
path = "mac";
if (is32bit)
path = path + "32";
else
path = path + "64";
System.out.println("Selected SWT classpath platform: " + path);
final ClassLoader parent = Main.class.getClassLoader();
final ArrayList<URL> urls = new ArrayList<URL>();
try {
final InputStream stream = parent.getResourceAsStream("libjars.properties");
final Properties properties = new Properties();
properties.load(stream);
stream.close();
String libs = (String) properties.get("contents");
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + aLib + "!/"));
}
libs = (String) properties.get("contents." + path);
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + path + "/" + aLib + "!/"));
}
} catch (final Throwable e1) {
}
try {
if (urls.size() > 0) {
final Method m1 = parent.getClass().getDeclaredMethod("addURL", URL.class);
m1.setAccessible(true);
for (final URL url : urls) {
m1.invoke(parent, url);
}
for (final URL url : ((URLClassLoader) parent).getURLs()) {
System.out.println(url);
}
}
final Class<?> class1 = parent.loadClass(LAUNCH_CLASS);
final Method method = class1.getMethod("launch", String[].class);
final Object[] methodArgs = new Object[] { args };
method.invoke(null, methodArgs);
} catch (final Throwable e) {
e.printStackTrace();
}
}
}
-
Attachment: build.xml
(Size: 2.23KB, Downloaded 165 times) -
Attachment: main.java
(Size: 2.24KB, Downloaded 196 times)
|
|
|
Re: Trouble running code on Windows [message #871586 is a reply to message #871311] |
Mon, 14 May 2012 13:04 |
Andi Thomas Messages: 38 Registered: July 2009 |
Member |
|
|
Attached are the build.xml and the main starting class
I've modified them slightly from the ones I actually use to remove any
possible reference to stuff I do for work, so there might be some typos
in there.
It should all be fairly obvious, let me know if you have questions.
In the build I'm currently only packaging for Win32/64. Its obvious and
easy to expand to all SWT platforms.
On 5/11/12 5:26 PM, Jesse Osiecki wrote:
> I'm messing with that code given in the error trying to get it to
> chainload my program. Two questions.
>
> 1) What does your ant build script look like?
>
> 2)I have completely forgotten and will probably ask later 8)
package com.andi;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Properties;
public class Main {
private static final String LAUNCH_CLASS = "com.andi.TheRealMainClass";
public static void main(final String[] args) {
final String osArch = System.getProperty("os.arch");
final String osName = System.getProperty("os.name").toUpperCase();
final boolean is32bit = !osArch.contains("64");
final boolean isWindows = osName.contains("WINDOWS");
final boolean isLinux = osName.contains("LINUX") || osName.contains("NIX");
final boolean isMac = osName.contains("MAC");
String path = "";
if (isWindows)
path = "win";
else if (isLinux)
path = "gtk";
else if (isMac)
path = "mac";
if (is32bit)
path = path + "32";
else
path = path + "64";
System.out.println("Selected SWT classpath platform: " + path);
final ClassLoader parent = Main.class.getClassLoader();
final ArrayList<URL> urls = new ArrayList<URL>();
try {
final InputStream stream = parent.getResourceAsStream("libjars.properties");
final Properties properties = new Properties();
properties.load(stream);
stream.close();
String libs = (String) properties.get("contents");
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + aLib + "!/"));
}
libs = (String) properties.get("contents." + path);
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + path + "/" + aLib + "!/"));
}
} catch (final Throwable e1) {
}
try {
if (urls.size() > 0) {
final Method m1 = parent.getClass().getDeclaredMethod("addURL", URL.class);
m1.setAccessible(true);
for (final URL url : urls) {
m1.invoke(parent, url);
}
for (final URL url : ((URLClassLoader) parent).getURLs()) {
System.out.println(url);
}
}
final Class<?> class1 = parent.loadClass(LAUNCH_CLASS);
final Method method = class1.getMethod("launch", String[].class);
final Object[] methodArgs = new Object[] { args };
method.invoke(null, methodArgs);
} catch (final Throwable e) {
e.printStackTrace();
}
}
}
-
Attachment: build.xml
(Size: 2.23KB, Downloaded 177 times) -
Attachment: main.java
(Size: 2.24KB, Downloaded 141 times)
|
|
|
Re: Trouble running code on Windows [message #871587 is a reply to message #871311] |
Mon, 14 May 2012 13:04 |
Andi Thomas Messages: 38 Registered: July 2009 |
Member |
|
|
Attached are the build.xml and the main starting class
I've modified them slightly from the ones I actually use to remove any
possible reference to stuff I do for work, so there might be some typos
in there.
It should all be fairly obvious, let me know if you have questions.
In the build I'm currently only packaging for Win32/64. Its obvious and
easy to expand to all SWT platforms.
On 5/11/12 5:26 PM, Jesse Osiecki wrote:
> I'm messing with that code given in the error trying to get it to
> chainload my program. Two questions.
>
> 1) What does your ant build script look like?
>
> 2)I have completely forgotten and will probably ask later 8)
package com.andi;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Properties;
public class Main {
private static final String LAUNCH_CLASS = "com.andi.TheRealMainClass";
public static void main(final String[] args) {
final String osArch = System.getProperty("os.arch");
final String osName = System.getProperty("os.name").toUpperCase();
final boolean is32bit = !osArch.contains("64");
final boolean isWindows = osName.contains("WINDOWS");
final boolean isLinux = osName.contains("LINUX") || osName.contains("NIX");
final boolean isMac = osName.contains("MAC");
String path = "";
if (isWindows)
path = "win";
else if (isLinux)
path = "gtk";
else if (isMac)
path = "mac";
if (is32bit)
path = path + "32";
else
path = path + "64";
System.out.println("Selected SWT classpath platform: " + path);
final ClassLoader parent = Main.class.getClassLoader();
final ArrayList<URL> urls = new ArrayList<URL>();
try {
final InputStream stream = parent.getResourceAsStream("libjars.properties");
final Properties properties = new Properties();
properties.load(stream);
stream.close();
String libs = (String) properties.get("contents");
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + aLib + "!/"));
}
libs = (String) properties.get("contents." + path);
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + path + "/" + aLib + "!/"));
}
} catch (final Throwable e1) {
}
try {
if (urls.size() > 0) {
final Method m1 = parent.getClass().getDeclaredMethod("addURL", URL.class);
m1.setAccessible(true);
for (final URL url : urls) {
m1.invoke(parent, url);
}
for (final URL url : ((URLClassLoader) parent).getURLs()) {
System.out.println(url);
}
}
final Class<?> class1 = parent.loadClass(LAUNCH_CLASS);
final Method method = class1.getMethod("launch", String[].class);
final Object[] methodArgs = new Object[] { args };
method.invoke(null, methodArgs);
} catch (final Throwable e) {
e.printStackTrace();
}
}
}
-
Attachment: build.xml
(Size: 2.23KB, Downloaded 147 times) -
Attachment: main.java
(Size: 2.24KB, Downloaded 172 times)
|
|
|
Re: Trouble running code on Windows [message #871589 is a reply to message #871311] |
Mon, 14 May 2012 13:04 |
Andi Thomas Messages: 38 Registered: July 2009 |
Member |
|
|
Attached are the build.xml and the main starting class
I've modified them slightly from the ones I actually use to remove any
possible reference to stuff I do for work, so there might be some typos
in there.
It should all be fairly obvious, let me know if you have questions.
In the build I'm currently only packaging for Win32/64. Its obvious and
easy to expand to all SWT platforms.
On 5/11/12 5:26 PM, Jesse Osiecki wrote:
> I'm messing with that code given in the error trying to get it to
> chainload my program. Two questions.
>
> 1) What does your ant build script look like?
>
> 2)I have completely forgotten and will probably ask later 8)
package com.andi;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Properties;
public class Main {
private static final String LAUNCH_CLASS = "com.andi.TheRealMainClass";
public static void main(final String[] args) {
final String osArch = System.getProperty("os.arch");
final String osName = System.getProperty("os.name").toUpperCase();
final boolean is32bit = !osArch.contains("64");
final boolean isWindows = osName.contains("WINDOWS");
final boolean isLinux = osName.contains("LINUX") || osName.contains("NIX");
final boolean isMac = osName.contains("MAC");
String path = "";
if (isWindows)
path = "win";
else if (isLinux)
path = "gtk";
else if (isMac)
path = "mac";
if (is32bit)
path = path + "32";
else
path = path + "64";
System.out.println("Selected SWT classpath platform: " + path);
final ClassLoader parent = Main.class.getClassLoader();
final ArrayList<URL> urls = new ArrayList<URL>();
try {
final InputStream stream = parent.getResourceAsStream("libjars.properties");
final Properties properties = new Properties();
properties.load(stream);
stream.close();
String libs = (String) properties.get("contents");
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + aLib + "!/"));
}
libs = (String) properties.get("contents." + path);
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + path + "/" + aLib + "!/"));
}
} catch (final Throwable e1) {
}
try {
if (urls.size() > 0) {
final Method m1 = parent.getClass().getDeclaredMethod("addURL", URL.class);
m1.setAccessible(true);
for (final URL url : urls) {
m1.invoke(parent, url);
}
for (final URL url : ((URLClassLoader) parent).getURLs()) {
System.out.println(url);
}
}
final Class<?> class1 = parent.loadClass(LAUNCH_CLASS);
final Method method = class1.getMethod("launch", String[].class);
final Object[] methodArgs = new Object[] { args };
method.invoke(null, methodArgs);
} catch (final Throwable e) {
e.printStackTrace();
}
}
}
-
Attachment: build.xml
(Size: 2.23KB, Downloaded 202 times) -
Attachment: main.java
(Size: 2.24KB, Downloaded 163 times)
|
|
|
Re: Trouble running code on Windows [message #871591 is a reply to message #871311] |
Mon, 14 May 2012 13:04 |
Andi Thomas Messages: 38 Registered: July 2009 |
Member |
|
|
Attached are the build.xml and the main starting class
I've modified them slightly from the ones I actually use to remove any
possible reference to stuff I do for work, so there might be some typos
in there.
It should all be fairly obvious, let me know if you have questions.
In the build I'm currently only packaging for Win32/64. Its obvious and
easy to expand to all SWT platforms.
On 5/11/12 5:26 PM, Jesse Osiecki wrote:
> I'm messing with that code given in the error trying to get it to
> chainload my program. Two questions.
>
> 1) What does your ant build script look like?
>
> 2)I have completely forgotten and will probably ask later 8)
package com.andi;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Properties;
public class Main {
private static final String LAUNCH_CLASS = "com.andi.TheRealMainClass";
public static void main(final String[] args) {
final String osArch = System.getProperty("os.arch");
final String osName = System.getProperty("os.name").toUpperCase();
final boolean is32bit = !osArch.contains("64");
final boolean isWindows = osName.contains("WINDOWS");
final boolean isLinux = osName.contains("LINUX") || osName.contains("NIX");
final boolean isMac = osName.contains("MAC");
String path = "";
if (isWindows)
path = "win";
else if (isLinux)
path = "gtk";
else if (isMac)
path = "mac";
if (is32bit)
path = path + "32";
else
path = path + "64";
System.out.println("Selected SWT classpath platform: " + path);
final ClassLoader parent = Main.class.getClassLoader();
final ArrayList<URL> urls = new ArrayList<URL>();
try {
final InputStream stream = parent.getResourceAsStream("libjars.properties");
final Properties properties = new Properties();
properties.load(stream);
stream.close();
String libs = (String) properties.get("contents");
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + aLib + "!/"));
}
libs = (String) properties.get("contents." + path);
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + path + "/" + aLib + "!/"));
}
} catch (final Throwable e1) {
}
try {
if (urls.size() > 0) {
final Method m1 = parent.getClass().getDeclaredMethod("addURL", URL.class);
m1.setAccessible(true);
for (final URL url : urls) {
m1.invoke(parent, url);
}
for (final URL url : ((URLClassLoader) parent).getURLs()) {
System.out.println(url);
}
}
final Class<?> class1 = parent.loadClass(LAUNCH_CLASS);
final Method method = class1.getMethod("launch", String[].class);
final Object[] methodArgs = new Object[] { args };
method.invoke(null, methodArgs);
} catch (final Throwable e) {
e.printStackTrace();
}
}
}
-
Attachment: build.xml
(Size: 2.23KB, Downloaded 158 times) -
Attachment: main.java
(Size: 2.24KB, Downloaded 167 times)
|
|
|
Re: Trouble running code on Windows [message #871593 is a reply to message #871311] |
Mon, 14 May 2012 13:04 |
Andi Thomas Messages: 38 Registered: July 2009 |
Member |
|
|
Attached are the build.xml and the main starting class
I've modified them slightly from the ones I actually use to remove any
possible reference to stuff I do for work, so there might be some typos
in there.
It should all be fairly obvious, let me know if you have questions.
In the build I'm currently only packaging for Win32/64. Its obvious and
easy to expand to all SWT platforms.
On 5/11/12 5:26 PM, Jesse Osiecki wrote:
> I'm messing with that code given in the error trying to get it to
> chainload my program. Two questions.
>
> 1) What does your ant build script look like?
>
> 2)I have completely forgotten and will probably ask later 8)
package com.andi;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Properties;
public class Main {
private static final String LAUNCH_CLASS = "com.andi.TheRealMainClass";
public static void main(final String[] args) {
final String osArch = System.getProperty("os.arch");
final String osName = System.getProperty("os.name").toUpperCase();
final boolean is32bit = !osArch.contains("64");
final boolean isWindows = osName.contains("WINDOWS");
final boolean isLinux = osName.contains("LINUX") || osName.contains("NIX");
final boolean isMac = osName.contains("MAC");
String path = "";
if (isWindows)
path = "win";
else if (isLinux)
path = "gtk";
else if (isMac)
path = "mac";
if (is32bit)
path = path + "32";
else
path = path + "64";
System.out.println("Selected SWT classpath platform: " + path);
final ClassLoader parent = Main.class.getClassLoader();
final ArrayList<URL> urls = new ArrayList<URL>();
try {
final InputStream stream = parent.getResourceAsStream("libjars.properties");
final Properties properties = new Properties();
properties.load(stream);
stream.close();
String libs = (String) properties.get("contents");
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + aLib + "!/"));
}
libs = (String) properties.get("contents." + path);
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + path + "/" + aLib + "!/"));
}
} catch (final Throwable e1) {
}
try {
if (urls.size() > 0) {
final Method m1 = parent.getClass().getDeclaredMethod("addURL", URL.class);
m1.setAccessible(true);
for (final URL url : urls) {
m1.invoke(parent, url);
}
for (final URL url : ((URLClassLoader) parent).getURLs()) {
System.out.println(url);
}
}
final Class<?> class1 = parent.loadClass(LAUNCH_CLASS);
final Method method = class1.getMethod("launch", String[].class);
final Object[] methodArgs = new Object[] { args };
method.invoke(null, methodArgs);
} catch (final Throwable e) {
e.printStackTrace();
}
}
}
-
Attachment: build.xml
(Size: 2.23KB, Downloaded 154 times) -
Attachment: main.java
(Size: 2.24KB, Downloaded 160 times)
|
|
|
Re: Trouble running code on Windows [message #871595 is a reply to message #871311] |
Mon, 14 May 2012 13:04 |
Andi Thomas Messages: 38 Registered: July 2009 |
Member |
|
|
Attached are the build.xml and the main starting class
I've modified them slightly from the ones I actually use to remove any
possible reference to stuff I do for work, so there might be some typos
in there.
It should all be fairly obvious, let me know if you have questions.
In the build I'm currently only packaging for Win32/64. Its obvious and
easy to expand to all SWT platforms.
On 5/11/12 5:26 PM, Jesse Osiecki wrote:
> I'm messing with that code given in the error trying to get it to
> chainload my program. Two questions.
>
> 1) What does your ant build script look like?
>
> 2)I have completely forgotten and will probably ask later 8)
package com.andi;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Properties;
public class Main {
private static final String LAUNCH_CLASS = "com.andi.TheRealMainClass";
public static void main(final String[] args) {
final String osArch = System.getProperty("os.arch");
final String osName = System.getProperty("os.name").toUpperCase();
final boolean is32bit = !osArch.contains("64");
final boolean isWindows = osName.contains("WINDOWS");
final boolean isLinux = osName.contains("LINUX") || osName.contains("NIX");
final boolean isMac = osName.contains("MAC");
String path = "";
if (isWindows)
path = "win";
else if (isLinux)
path = "gtk";
else if (isMac)
path = "mac";
if (is32bit)
path = path + "32";
else
path = path + "64";
System.out.println("Selected SWT classpath platform: " + path);
final ClassLoader parent = Main.class.getClassLoader();
final ArrayList<URL> urls = new ArrayList<URL>();
try {
final InputStream stream = parent.getResourceAsStream("libjars.properties");
final Properties properties = new Properties();
properties.load(stream);
stream.close();
String libs = (String) properties.get("contents");
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + aLib + "!/"));
}
libs = (String) properties.get("contents." + path);
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + path + "/" + aLib + "!/"));
}
} catch (final Throwable e1) {
}
try {
if (urls.size() > 0) {
final Method m1 = parent.getClass().getDeclaredMethod("addURL", URL.class);
m1.setAccessible(true);
for (final URL url : urls) {
m1.invoke(parent, url);
}
for (final URL url : ((URLClassLoader) parent).getURLs()) {
System.out.println(url);
}
}
final Class<?> class1 = parent.loadClass(LAUNCH_CLASS);
final Method method = class1.getMethod("launch", String[].class);
final Object[] methodArgs = new Object[] { args };
method.invoke(null, methodArgs);
} catch (final Throwable e) {
e.printStackTrace();
}
}
}
-
Attachment: build.xml
(Size: 2.23KB, Downloaded 136 times) -
Attachment: main.java
(Size: 2.24KB, Downloaded 167 times)
|
|
|
Re: Trouble running code on Windows [message #871598 is a reply to message #871311] |
Mon, 14 May 2012 13:04 |
Andi Thomas Messages: 38 Registered: July 2009 |
Member |
|
|
Attached are the build.xml and the main starting class
I've modified them slightly from the ones I actually use to remove any
possible reference to stuff I do for work, so there might be some typos
in there.
It should all be fairly obvious, let me know if you have questions.
In the build I'm currently only packaging for Win32/64. Its obvious and
easy to expand to all SWT platforms.
On 5/11/12 5:26 PM, Jesse Osiecki wrote:
> I'm messing with that code given in the error trying to get it to
> chainload my program. Two questions.
>
> 1) What does your ant build script look like?
>
> 2)I have completely forgotten and will probably ask later 8)
package com.andi;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Properties;
public class Main {
private static final String LAUNCH_CLASS = "com.andi.TheRealMainClass";
public static void main(final String[] args) {
final String osArch = System.getProperty("os.arch");
final String osName = System.getProperty("os.name").toUpperCase();
final boolean is32bit = !osArch.contains("64");
final boolean isWindows = osName.contains("WINDOWS");
final boolean isLinux = osName.contains("LINUX") || osName.contains("NIX");
final boolean isMac = osName.contains("MAC");
String path = "";
if (isWindows)
path = "win";
else if (isLinux)
path = "gtk";
else if (isMac)
path = "mac";
if (is32bit)
path = path + "32";
else
path = path + "64";
System.out.println("Selected SWT classpath platform: " + path);
final ClassLoader parent = Main.class.getClassLoader();
final ArrayList<URL> urls = new ArrayList<URL>();
try {
final InputStream stream = parent.getResourceAsStream("libjars.properties");
final Properties properties = new Properties();
properties.load(stream);
stream.close();
String libs = (String) properties.get("contents");
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + aLib + "!/"));
}
libs = (String) properties.get("contents." + path);
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + path + "/" + aLib + "!/"));
}
} catch (final Throwable e1) {
}
try {
if (urls.size() > 0) {
final Method m1 = parent.getClass().getDeclaredMethod("addURL", URL.class);
m1.setAccessible(true);
for (final URL url : urls) {
m1.invoke(parent, url);
}
for (final URL url : ((URLClassLoader) parent).getURLs()) {
System.out.println(url);
}
}
final Class<?> class1 = parent.loadClass(LAUNCH_CLASS);
final Method method = class1.getMethod("launch", String[].class);
final Object[] methodArgs = new Object[] { args };
method.invoke(null, methodArgs);
} catch (final Throwable e) {
e.printStackTrace();
}
}
}
-
Attachment: build.xml
(Size: 2.23KB, Downloaded 160 times) -
Attachment: main.java
(Size: 2.24KB, Downloaded 141 times)
|
|
|
Re: Trouble running code on Windows [message #871599 is a reply to message #871311] |
Mon, 14 May 2012 13:04 |
Andi Thomas Messages: 38 Registered: July 2009 |
Member |
|
|
Attached are the build.xml and the main starting class
I've modified them slightly from the ones I actually use to remove any
possible reference to stuff I do for work, so there might be some typos
in there.
It should all be fairly obvious, let me know if you have questions.
In the build I'm currently only packaging for Win32/64. Its obvious and
easy to expand to all SWT platforms.
On 5/11/12 5:26 PM, Jesse Osiecki wrote:
> I'm messing with that code given in the error trying to get it to
> chainload my program. Two questions.
>
> 1) What does your ant build script look like?
>
> 2)I have completely forgotten and will probably ask later 8)
package com.andi;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Properties;
public class Main {
private static final String LAUNCH_CLASS = "com.andi.TheRealMainClass";
public static void main(final String[] args) {
final String osArch = System.getProperty("os.arch");
final String osName = System.getProperty("os.name").toUpperCase();
final boolean is32bit = !osArch.contains("64");
final boolean isWindows = osName.contains("WINDOWS");
final boolean isLinux = osName.contains("LINUX") || osName.contains("NIX");
final boolean isMac = osName.contains("MAC");
String path = "";
if (isWindows)
path = "win";
else if (isLinux)
path = "gtk";
else if (isMac)
path = "mac";
if (is32bit)
path = path + "32";
else
path = path + "64";
System.out.println("Selected SWT classpath platform: " + path);
final ClassLoader parent = Main.class.getClassLoader();
final ArrayList<URL> urls = new ArrayList<URL>();
try {
final InputStream stream = parent.getResourceAsStream("libjars.properties");
final Properties properties = new Properties();
properties.load(stream);
stream.close();
String libs = (String) properties.get("contents");
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + aLib + "!/"));
}
libs = (String) properties.get("contents." + path);
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + path + "/" + aLib + "!/"));
}
} catch (final Throwable e1) {
}
try {
if (urls.size() > 0) {
final Method m1 = parent.getClass().getDeclaredMethod("addURL", URL.class);
m1.setAccessible(true);
for (final URL url : urls) {
m1.invoke(parent, url);
}
for (final URL url : ((URLClassLoader) parent).getURLs()) {
System.out.println(url);
}
}
final Class<?> class1 = parent.loadClass(LAUNCH_CLASS);
final Method method = class1.getMethod("launch", String[].class);
final Object[] methodArgs = new Object[] { args };
method.invoke(null, methodArgs);
} catch (final Throwable e) {
e.printStackTrace();
}
}
}
-
Attachment: build.xml
(Size: 2.23KB, Downloaded 163 times) -
Attachment: main.java
(Size: 2.24KB, Downloaded 264 times)
|
|
|
Re: Trouble running code on Windows [message #871601 is a reply to message #871311] |
Mon, 14 May 2012 13:04 |
Andi Thomas Messages: 38 Registered: July 2009 |
Member |
|
|
Attached are the build.xml and the main starting class
I've modified them slightly from the ones I actually use to remove any
possible reference to stuff I do for work, so there might be some typos
in there.
It should all be fairly obvious, let me know if you have questions.
In the build I'm currently only packaging for Win32/64. Its obvious and
easy to expand to all SWT platforms.
On 5/11/12 5:26 PM, Jesse Osiecki wrote:
> I'm messing with that code given in the error trying to get it to
> chainload my program. Two questions.
>
> 1) What does your ant build script look like?
>
> 2)I have completely forgotten and will probably ask later 8)
package com.andi;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Properties;
public class Main {
private static final String LAUNCH_CLASS = "com.andi.TheRealMainClass";
public static void main(final String[] args) {
final String osArch = System.getProperty("os.arch");
final String osName = System.getProperty("os.name").toUpperCase();
final boolean is32bit = !osArch.contains("64");
final boolean isWindows = osName.contains("WINDOWS");
final boolean isLinux = osName.contains("LINUX") || osName.contains("NIX");
final boolean isMac = osName.contains("MAC");
String path = "";
if (isWindows)
path = "win";
else if (isLinux)
path = "gtk";
else if (isMac)
path = "mac";
if (is32bit)
path = path + "32";
else
path = path + "64";
System.out.println("Selected SWT classpath platform: " + path);
final ClassLoader parent = Main.class.getClassLoader();
final ArrayList<URL> urls = new ArrayList<URL>();
try {
final InputStream stream = parent.getResourceAsStream("libjars.properties");
final Properties properties = new Properties();
properties.load(stream);
stream.close();
String libs = (String) properties.get("contents");
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + aLib + "!/"));
}
libs = (String) properties.get("contents." + path);
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + path + "/" + aLib + "!/"));
}
} catch (final Throwable e1) {
}
try {
if (urls.size() > 0) {
final Method m1 = parent.getClass().getDeclaredMethod("addURL", URL.class);
m1.setAccessible(true);
for (final URL url : urls) {
m1.invoke(parent, url);
}
for (final URL url : ((URLClassLoader) parent).getURLs()) {
System.out.println(url);
}
}
final Class<?> class1 = parent.loadClass(LAUNCH_CLASS);
final Method method = class1.getMethod("launch", String[].class);
final Object[] methodArgs = new Object[] { args };
method.invoke(null, methodArgs);
} catch (final Throwable e) {
e.printStackTrace();
}
}
}
-
Attachment: build.xml
(Size: 2.23KB, Downloaded 157 times) -
Attachment: main.java
(Size: 2.24KB, Downloaded 144 times)
|
|
|
Re: Trouble running code on Windows [message #871603 is a reply to message #871311] |
Mon, 14 May 2012 13:04 |
Andi Thomas Messages: 38 Registered: July 2009 |
Member |
|
|
Attached are the build.xml and the main starting class
I've modified them slightly from the ones I actually use to remove any
possible reference to stuff I do for work, so there might be some typos
in there.
It should all be fairly obvious, let me know if you have questions.
In the build I'm currently only packaging for Win32/64. Its obvious and
easy to expand to all SWT platforms.
On 5/11/12 5:26 PM, Jesse Osiecki wrote:
> I'm messing with that code given in the error trying to get it to
> chainload my program. Two questions.
>
> 1) What does your ant build script look like?
>
> 2)I have completely forgotten and will probably ask later 8)
package com.andi;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Properties;
public class Main {
private static final String LAUNCH_CLASS = "com.andi.TheRealMainClass";
public static void main(final String[] args) {
final String osArch = System.getProperty("os.arch");
final String osName = System.getProperty("os.name").toUpperCase();
final boolean is32bit = !osArch.contains("64");
final boolean isWindows = osName.contains("WINDOWS");
final boolean isLinux = osName.contains("LINUX") || osName.contains("NIX");
final boolean isMac = osName.contains("MAC");
String path = "";
if (isWindows)
path = "win";
else if (isLinux)
path = "gtk";
else if (isMac)
path = "mac";
if (is32bit)
path = path + "32";
else
path = path + "64";
System.out.println("Selected SWT classpath platform: " + path);
final ClassLoader parent = Main.class.getClassLoader();
final ArrayList<URL> urls = new ArrayList<URL>();
try {
final InputStream stream = parent.getResourceAsStream("libjars.properties");
final Properties properties = new Properties();
properties.load(stream);
stream.close();
String libs = (String) properties.get("contents");
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + aLib + "!/"));
}
libs = (String) properties.get("contents." + path);
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + path + "/" + aLib + "!/"));
}
} catch (final Throwable e1) {
}
try {
if (urls.size() > 0) {
final Method m1 = parent.getClass().getDeclaredMethod("addURL", URL.class);
m1.setAccessible(true);
for (final URL url : urls) {
m1.invoke(parent, url);
}
for (final URL url : ((URLClassLoader) parent).getURLs()) {
System.out.println(url);
}
}
final Class<?> class1 = parent.loadClass(LAUNCH_CLASS);
final Method method = class1.getMethod("launch", String[].class);
final Object[] methodArgs = new Object[] { args };
method.invoke(null, methodArgs);
} catch (final Throwable e) {
e.printStackTrace();
}
}
}
-
Attachment: build.xml
(Size: 2.23KB, Downloaded 219 times) -
Attachment: main.java
(Size: 2.24KB, Downloaded 163 times)
|
|
|
Re: Trouble running code on Windows [message #871606 is a reply to message #871311] |
Mon, 14 May 2012 13:04 |
Andi Thomas Messages: 38 Registered: July 2009 |
Member |
|
|
Attached are the build.xml and the main starting class
I've modified them slightly from the ones I actually use to remove any
possible reference to stuff I do for work, so there might be some typos
in there.
It should all be fairly obvious, let me know if you have questions.
In the build I'm currently only packaging for Win32/64. Its obvious and
easy to expand to all SWT platforms.
On 5/11/12 5:26 PM, Jesse Osiecki wrote:
> I'm messing with that code given in the error trying to get it to
> chainload my program. Two questions.
>
> 1) What does your ant build script look like?
>
> 2)I have completely forgotten and will probably ask later 8)
package com.andi;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Properties;
public class Main {
private static final String LAUNCH_CLASS = "com.andi.TheRealMainClass";
public static void main(final String[] args) {
final String osArch = System.getProperty("os.arch");
final String osName = System.getProperty("os.name").toUpperCase();
final boolean is32bit = !osArch.contains("64");
final boolean isWindows = osName.contains("WINDOWS");
final boolean isLinux = osName.contains("LINUX") || osName.contains("NIX");
final boolean isMac = osName.contains("MAC");
String path = "";
if (isWindows)
path = "win";
else if (isLinux)
path = "gtk";
else if (isMac)
path = "mac";
if (is32bit)
path = path + "32";
else
path = path + "64";
System.out.println("Selected SWT classpath platform: " + path);
final ClassLoader parent = Main.class.getClassLoader();
final ArrayList<URL> urls = new ArrayList<URL>();
try {
final InputStream stream = parent.getResourceAsStream("libjars.properties");
final Properties properties = new Properties();
properties.load(stream);
stream.close();
String libs = (String) properties.get("contents");
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + aLib + "!/"));
}
libs = (String) properties.get("contents." + path);
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + path + "/" + aLib + "!/"));
}
} catch (final Throwable e1) {
}
try {
if (urls.size() > 0) {
final Method m1 = parent.getClass().getDeclaredMethod("addURL", URL.class);
m1.setAccessible(true);
for (final URL url : urls) {
m1.invoke(parent, url);
}
for (final URL url : ((URLClassLoader) parent).getURLs()) {
System.out.println(url);
}
}
final Class<?> class1 = parent.loadClass(LAUNCH_CLASS);
final Method method = class1.getMethod("launch", String[].class);
final Object[] methodArgs = new Object[] { args };
method.invoke(null, methodArgs);
} catch (final Throwable e) {
e.printStackTrace();
}
}
}
-
Attachment: build.xml
(Size: 2.23KB, Downloaded 188 times) -
Attachment: main.java
(Size: 2.24KB, Downloaded 147 times)
|
|
|
Re: Trouble running code on Windows [message #871608 is a reply to message #871311] |
Mon, 14 May 2012 13:04 |
Andi Thomas Messages: 38 Registered: July 2009 |
Member |
|
|
Attached are the build.xml and the main starting class
I've modified them slightly from the ones I actually use to remove any
possible reference to stuff I do for work, so there might be some typos
in there.
It should all be fairly obvious, let me know if you have questions.
In the build I'm currently only packaging for Win32/64. Its obvious and
easy to expand to all SWT platforms.
On 5/11/12 5:26 PM, Jesse Osiecki wrote:
> I'm messing with that code given in the error trying to get it to
> chainload my program. Two questions.
>
> 1) What does your ant build script look like?
>
> 2)I have completely forgotten and will probably ask later 8)
package com.andi;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Properties;
public class Main {
private static final String LAUNCH_CLASS = "com.andi.TheRealMainClass";
public static void main(final String[] args) {
final String osArch = System.getProperty("os.arch");
final String osName = System.getProperty("os.name").toUpperCase();
final boolean is32bit = !osArch.contains("64");
final boolean isWindows = osName.contains("WINDOWS");
final boolean isLinux = osName.contains("LINUX") || osName.contains("NIX");
final boolean isMac = osName.contains("MAC");
String path = "";
if (isWindows)
path = "win";
else if (isLinux)
path = "gtk";
else if (isMac)
path = "mac";
if (is32bit)
path = path + "32";
else
path = path + "64";
System.out.println("Selected SWT classpath platform: " + path);
final ClassLoader parent = Main.class.getClassLoader();
final ArrayList<URL> urls = new ArrayList<URL>();
try {
final InputStream stream = parent.getResourceAsStream("libjars.properties");
final Properties properties = new Properties();
properties.load(stream);
stream.close();
String libs = (String) properties.get("contents");
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + aLib + "!/"));
}
libs = (String) properties.get("contents." + path);
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + path + "/" + aLib + "!/"));
}
} catch (final Throwable e1) {
}
try {
if (urls.size() > 0) {
final Method m1 = parent.getClass().getDeclaredMethod("addURL", URL.class);
m1.setAccessible(true);
for (final URL url : urls) {
m1.invoke(parent, url);
}
for (final URL url : ((URLClassLoader) parent).getURLs()) {
System.out.println(url);
}
}
final Class<?> class1 = parent.loadClass(LAUNCH_CLASS);
final Method method = class1.getMethod("launch", String[].class);
final Object[] methodArgs = new Object[] { args };
method.invoke(null, methodArgs);
} catch (final Throwable e) {
e.printStackTrace();
}
}
}
-
Attachment: build.xml
(Size: 2.23KB, Downloaded 152 times) -
Attachment: main.java
(Size: 2.24KB, Downloaded 150 times)
|
|
|
Re: Trouble running code on Windows [message #871611 is a reply to message #871311] |
Mon, 14 May 2012 13:04 |
Andi Thomas Messages: 38 Registered: July 2009 |
Member |
|
|
Attached are the build.xml and the main starting class
I've modified them slightly from the ones I actually use to remove any
possible reference to stuff I do for work, so there might be some typos
in there.
It should all be fairly obvious, let me know if you have questions.
In the build I'm currently only packaging for Win32/64. Its obvious and
easy to expand to all SWT platforms.
On 5/11/12 5:26 PM, Jesse Osiecki wrote:
> I'm messing with that code given in the error trying to get it to
> chainload my program. Two questions.
>
> 1) What does your ant build script look like?
>
> 2)I have completely forgotten and will probably ask later 8)
package com.andi;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Properties;
public class Main {
private static final String LAUNCH_CLASS = "com.andi.TheRealMainClass";
public static void main(final String[] args) {
final String osArch = System.getProperty("os.arch");
final String osName = System.getProperty("os.name").toUpperCase();
final boolean is32bit = !osArch.contains("64");
final boolean isWindows = osName.contains("WINDOWS");
final boolean isLinux = osName.contains("LINUX") || osName.contains("NIX");
final boolean isMac = osName.contains("MAC");
String path = "";
if (isWindows)
path = "win";
else if (isLinux)
path = "gtk";
else if (isMac)
path = "mac";
if (is32bit)
path = path + "32";
else
path = path + "64";
System.out.println("Selected SWT classpath platform: " + path);
final ClassLoader parent = Main.class.getClassLoader();
final ArrayList<URL> urls = new ArrayList<URL>();
try {
final InputStream stream = parent.getResourceAsStream("libjars.properties");
final Properties properties = new Properties();
properties.load(stream);
stream.close();
String libs = (String) properties.get("contents");
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + aLib + "!/"));
}
libs = (String) properties.get("contents." + path);
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + path + "/" + aLib + "!/"));
}
} catch (final Throwable e1) {
}
try {
if (urls.size() > 0) {
final Method m1 = parent.getClass().getDeclaredMethod("addURL", URL.class);
m1.setAccessible(true);
for (final URL url : urls) {
m1.invoke(parent, url);
}
for (final URL url : ((URLClassLoader) parent).getURLs()) {
System.out.println(url);
}
}
final Class<?> class1 = parent.loadClass(LAUNCH_CLASS);
final Method method = class1.getMethod("launch", String[].class);
final Object[] methodArgs = new Object[] { args };
method.invoke(null, methodArgs);
} catch (final Throwable e) {
e.printStackTrace();
}
}
}
-
Attachment: build.xml
(Size: 2.23KB, Downloaded 204 times) -
Attachment: main.java
(Size: 2.24KB, Downloaded 171 times)
|
|
|
Re: Trouble running code on Windows [message #871616 is a reply to message #871311] |
Mon, 14 May 2012 13:04 |
Andi Thomas Messages: 38 Registered: July 2009 |
Member |
|
|
Attached are the build.xml and the main starting class
I've modified them slightly from the ones I actually use to remove any
possible reference to stuff I do for work, so there might be some typos
in there.
It should all be fairly obvious, let me know if you have questions.
In the build I'm currently only packaging for Win32/64. Its obvious and
easy to expand to all SWT platforms.
On 5/11/12 5:26 PM, Jesse Osiecki wrote:
> I'm messing with that code given in the error trying to get it to
> chainload my program. Two questions.
>
> 1) What does your ant build script look like?
>
> 2)I have completely forgotten and will probably ask later 8)
package com.andi;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Properties;
public class Main {
private static final String LAUNCH_CLASS = "com.andi.TheRealMainClass";
public static void main(final String[] args) {
final String osArch = System.getProperty("os.arch");
final String osName = System.getProperty("os.name").toUpperCase();
final boolean is32bit = !osArch.contains("64");
final boolean isWindows = osName.contains("WINDOWS");
final boolean isLinux = osName.contains("LINUX") || osName.contains("NIX");
final boolean isMac = osName.contains("MAC");
String path = "";
if (isWindows)
path = "win";
else if (isLinux)
path = "gtk";
else if (isMac)
path = "mac";
if (is32bit)
path = path + "32";
else
path = path + "64";
System.out.println("Selected SWT classpath platform: " + path);
final ClassLoader parent = Main.class.getClassLoader();
final ArrayList<URL> urls = new ArrayList<URL>();
try {
final InputStream stream = parent.getResourceAsStream("libjars.properties");
final Properties properties = new Properties();
properties.load(stream);
stream.close();
String libs = (String) properties.get("contents");
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + aLib + "!/"));
}
libs = (String) properties.get("contents." + path);
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + path + "/" + aLib + "!/"));
}
} catch (final Throwable e1) {
}
try {
if (urls.size() > 0) {
final Method m1 = parent.getClass().getDeclaredMethod("addURL", URL.class);
m1.setAccessible(true);
for (final URL url : urls) {
m1.invoke(parent, url);
}
for (final URL url : ((URLClassLoader) parent).getURLs()) {
System.out.println(url);
}
}
final Class<?> class1 = parent.loadClass(LAUNCH_CLASS);
final Method method = class1.getMethod("launch", String[].class);
final Object[] methodArgs = new Object[] { args };
method.invoke(null, methodArgs);
} catch (final Throwable e) {
e.printStackTrace();
}
}
}
-
Attachment: build.xml
(Size: 2.23KB, Downloaded 167 times) -
Attachment: main.java
(Size: 2.24KB, Downloaded 204 times)
|
|
|
Re: Trouble running code on Windows [message #871617 is a reply to message #871311] |
Mon, 14 May 2012 13:04 |
Andi Thomas Messages: 38 Registered: July 2009 |
Member |
|
|
Attached are the build.xml and the main starting class
I've modified them slightly from the ones I actually use to remove any
possible reference to stuff I do for work, so there might be some typos
in there.
It should all be fairly obvious, let me know if you have questions.
In the build I'm currently only packaging for Win32/64. Its obvious and
easy to expand to all SWT platforms.
On 5/11/12 5:26 PM, Jesse Osiecki wrote:
> I'm messing with that code given in the error trying to get it to
> chainload my program. Two questions.
>
> 1) What does your ant build script look like?
>
> 2)I have completely forgotten and will probably ask later 8)
package com.andi;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Properties;
public class Main {
private static final String LAUNCH_CLASS = "com.andi.TheRealMainClass";
public static void main(final String[] args) {
final String osArch = System.getProperty("os.arch");
final String osName = System.getProperty("os.name").toUpperCase();
final boolean is32bit = !osArch.contains("64");
final boolean isWindows = osName.contains("WINDOWS");
final boolean isLinux = osName.contains("LINUX") || osName.contains("NIX");
final boolean isMac = osName.contains("MAC");
String path = "";
if (isWindows)
path = "win";
else if (isLinux)
path = "gtk";
else if (isMac)
path = "mac";
if (is32bit)
path = path + "32";
else
path = path + "64";
System.out.println("Selected SWT classpath platform: " + path);
final ClassLoader parent = Main.class.getClassLoader();
final ArrayList<URL> urls = new ArrayList<URL>();
try {
final InputStream stream = parent.getResourceAsStream("libjars.properties");
final Properties properties = new Properties();
properties.load(stream);
stream.close();
String libs = (String) properties.get("contents");
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + aLib + "!/"));
}
libs = (String) properties.get("contents." + path);
for (final String aLib : libs.split(";")) {
urls.add(new URL("jar:rsrc:lib/" + path + "/" + aLib + "!/"));
}
} catch (final Throwable e1) {
}
try {
if (urls.size() > 0) {
final Method m1 = parent.getClass().getDeclaredMethod("addURL", URL.class);
m1.setAccessible(true);
for (final URL url : urls) {
m1.invoke(parent, url);
}
for (final URL url : ((URLClassLoader) parent).getURLs()) {
System.out.println(url);
}
}
final Class<?> class1 = parent.loadClass(LAUNCH_CLASS);
final Method method = class1.getMethod("launch", String[].class);
final Object[] methodArgs = new Object[] { args };
method.invoke(null, methodArgs);
} catch (final Throwable e) {
e.printStackTrace();
}
}
}
-
Attachment: build.xml
(Size: 2.23KB, Downloaded 151 times) -
Attachment: main.java
(Size: 2.24KB, Downloaded 150 times)
|
|
| |
Goto Forum:
Current Time: Fri Apr 26 08:56:13 GMT 2024
Powered by FUDForum. Page generated in 0.05475 seconds
|