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 19:22  |
Eclipse User |
|
|
|
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 09:04   |
Eclipse User |
|
|
|
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 171 times)
Attachment: main.java
(Size: 2.24KB, Downloaded 204 times)
|
|
|
Re: Trouble running code on Windows [message #871580 is a reply to message #871311] |
Mon, 14 May 2012 09:04   |
Eclipse User |
|
|
|
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 252 times)
Attachment: main.java
(Size: 2.24KB, Downloaded 183 times)
|
|
|
Re: Trouble running code on Windows [message #871583 is a reply to message #871311] |
Mon, 14 May 2012 09:04   |
Eclipse User |
|
|
|
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 231 times)
|
|
|
Re: Trouble running code on Windows [message #871586 is a reply to message #871311] |
Mon, 14 May 2012 09:04   |
Eclipse User |
|
|
|
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 200 times)
Attachment: main.java
(Size: 2.24KB, Downloaded 172 times)
|
|
|
Re: Trouble running code on Windows [message #871587 is a reply to message #871311] |
Mon, 14 May 2012 09:04   |
Eclipse User |
|
|
|
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 172 times)
Attachment: main.java
(Size: 2.24KB, Downloaded 195 times)
|
|
|
Re: Trouble running code on Windows [message #871589 is a reply to message #871311] |
Mon, 14 May 2012 09:04   |
Eclipse User |
|
|
|
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 230 times)
Attachment: main.java
(Size: 2.24KB, Downloaded 189 times)
|
|
|
Re: Trouble running code on Windows [message #871591 is a reply to message #871311] |
Mon, 14 May 2012 09:04   |
Eclipse User |
|
|
|
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 175 times)
Attachment: main.java
(Size: 2.24KB, Downloaded 185 times)
|
|
|
Re: Trouble running code on Windows [message #871593 is a reply to message #871311] |
Mon, 14 May 2012 09:04   |
Eclipse User |
|
|
|
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 176 times)
Attachment: main.java
(Size: 2.24KB, Downloaded 180 times)
|
|
|
Re: Trouble running code on Windows [message #871595 is a reply to message #871311] |
Mon, 14 May 2012 09:04   |
Eclipse User |
|
|
|
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 196 times)
|
|
|
Re: Trouble running code on Windows [message #871598 is a reply to message #871311] |
Mon, 14 May 2012 09:04   |
Eclipse User |
|
|
|
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 181 times)
Attachment: main.java
(Size: 2.24KB, Downloaded 166 times)
|
|
|
Re: Trouble running code on Windows [message #871599 is a reply to message #871311] |
Mon, 14 May 2012 09:04   |
Eclipse User |
|
|
|
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 186 times)
Attachment: main.java
(Size: 2.24KB, Downloaded 300 times)
|
|
|
Re: Trouble running code on Windows [message #871601 is a reply to message #871311] |
Mon, 14 May 2012 09:04   |
Eclipse User |
|
|
|
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 172 times)
|
|
|
Re: Trouble running code on Windows [message #871603 is a reply to message #871311] |
Mon, 14 May 2012 09:04   |
Eclipse User |
|
|
|
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 238 times)
Attachment: main.java
(Size: 2.24KB, Downloaded 196 times)
|
|
|
Re: Trouble running code on Windows [message #871606 is a reply to message #871311] |
Mon, 14 May 2012 09:04   |
Eclipse User |
|
|
|
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 210 times)
Attachment: main.java
(Size: 2.24KB, Downloaded 178 times)
|
|
|
Re: Trouble running code on Windows [message #871608 is a reply to message #871311] |
Mon, 14 May 2012 09:04   |
Eclipse User |
|
|
|
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 172 times)
|
|
|
Re: Trouble running code on Windows [message #871611 is a reply to message #871311] |
Mon, 14 May 2012 09:04   |
Eclipse User |
|
|
|
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 229 times)
Attachment: main.java
(Size: 2.24KB, Downloaded 193 times)
|
|
|
Re: Trouble running code on Windows [message #871616 is a reply to message #871311] |
Mon, 14 May 2012 09:04   |
Eclipse User |
|
|
|
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 191 times)
Attachment: main.java
(Size: 2.24KB, Downloaded 233 times)
|
|
|
Re: Trouble running code on Windows [message #871617 is a reply to message #871311] |
Mon, 14 May 2012 09:04   |
Eclipse User |
|
|
|
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 168 times)
Attachment: main.java
(Size: 2.24KB, Downloaded 174 times)
|
|
| |
Goto Forum:
Current Time: Sun Jul 27 02:28:34 EDT 2025
Powered by FUDForum. Page generated in 0.09158 seconds
|