Login  Register

Re: OpenGL + OS X

Posted by philjord on Feb 15, 2016; 8:58pm
URL: https://forum.jogamp.org/OpenGL-OS-X-tp4036147p4036259.html

Thomas,
You don't even need to bundle Java, just Java3D and Jogl.

But you have to disable the ext folder Java3D.

Which is done by putting this
-Djava.ext.dirs=.\none\
into the Java arguments, it's simple and it works every time.

However the catch it you can't use any other extension like Java Media Framework.

Though I've never met a Java app that didn't bundle the extension it wanted to use, so I feel that it's not a strong reason not to disable the ext folder.

If you MUST have ext enabled you can do the following if you trust your users a LOT.

public static boolean checkForInstalledJ3d()
        {
                // check for java3d installed
                String extProp = System.getProperties().getProperty("java.ext.dirs");
                if (extProp != null)
                {
                        ArrayList<File> preinstalledJ3dJars = new ArrayList<File>();
                        String[] paths = extProp.split(ps);
                        for (String path : paths)
                        {
                                File folder = new File(path);
                                if (folder.exists() && folder.isDirectory())
                                {
                                        File[] listOfFiles = folder.listFiles();
                                        for (int i = 0; i < listOfFiles.length; i++)
                                        {
                                                if (listOfFiles[i].isFile())
                                                {
                                                        if (listOfFiles[i].getName().indexOf("j3d") != -1 || listOfFiles[i].getName().indexOf("vecmath") != -1)
                                                        {
                                                                preinstalledJ3dJars.add(listOfFiles[i]);

                                                        }
                                                }
                                        }
                                }
                        }

                        if (preinstalledJ3dJars.size() > 0)
                        {
                                String mess = "There appears to be some pre installed Java3d files.";
                                mess += "\nThey need to be removed (moved or deleted), otherwise this application will almost certainly fail.";


//Possibly just for fun try and delete the file for them too!
                                for (File jf : preinstalledJ3dJars)
                                {
                                        mess += "\n" + jf.getPath();
                                }
                                System.out.println(mess);
                                int result = JOptionPane.showConfirmDialog(null, mess, "Pre installed Java3d detected, do you want to attempt deletion?", JOptionPane.YES_NO_OPTION,
                                                JOptionPane.WARNING_MESSAGE);
                                if (result == JOptionPane.YES_OPTION)
                                {
                                        boolean success = true;
                                        for (File jf : preinstalledJ3dJars)
                                        {
                                                boolean fileIsNotLocked = jf.renameTo(jf);

                                                System.out.println("jf " + jf + " " + fileIsNotLocked);
                                                success &= jf.delete();
                                        }
                                        JOptionPane.showMessageDialog(null, success ? "Success!" : "Failed, please remove manually and restart");
                                }
                                return true;
                        }

                }

                return false;
        }