Directly using VirtualBox from Java #5

Merged
NorbiPeti merged 60 commits from directvb into master 2019-04-18 23:29:21 +00:00
3 changed files with 33 additions and 4 deletions
Showing only changes of commit 11de752732 - Show all commits

View file

@ -15,12 +15,12 @@ I plan on making a series where I show the whole process of creating this projec
*If you don't meet these requirements, you may need to compile the files for yourself. If you do please send the compiled version to me so more people can download it.*
* OS X; Ubuntu 16.04/18.04
* VirtualBox 5.2
* VirtualBox 6.0
* Spgiot/Bukkit 1.8/1.9/1.12
* Java 8
### Untested:
* Any Linux versions
* Other Linux versions
* Other VirtualBox versions (code modifications are probably necessary)
* Other Spigot/Bukkit versions
* Other Java versions
@ -66,3 +66,9 @@ Due to the way it works, it automatically plays every sound from the virtual mac
### Special thanks:
* The creators of VirtualBox for making it open-source and kind of easy to use (though I had minor issues as the documentation doesn't really tell me how to write a new frontend :P and that I needed to learn how machines work - especially keyboards)
* @iiegit for testing and more testing for the non-Windows version
# Known issues
## Port remains open (cannot bind to port)
**Fix:** Close all VirtualBox instances and wait 10 seconds.
**Cause:** Possibly it happens because the plugin creates the VBoxSVC process, which thus inherits file descriptors such as the open server port.

View file

@ -87,5 +87,10 @@
<artifactId>jnr-ffi</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>com.aparapi</groupId>
<artifactId>aparapi</artifactId>
<version>1.10.0</version>
</dependency>
</dependencies>
</project>

View file

@ -1,19 +1,37 @@
package sznp.virtualcomputer;
import com.aparapi.Kernel;
import com.aparapi.Range;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import jnr.ffi.LibraryLoader;
import java.io.File;
import java.nio.ByteBuffer;
import java.util.Arrays;
public class Test {
public static void main(String[] args) {
System.out.println(new File("").getAbsolutePath());
/*System.out.println(new File("").getAbsolutePath());
PXCLib pxc = LibraryLoader.create(PXCLib.class).search(new File("").getAbsolutePath()).load("pxc");
ByteBuffer bb = ByteBuffer.allocateDirect(2);
long[] x = new long[]{Pointer.nativeValue(Native.getDirectBufferPointer(bb))};
pxc.convert(new int[]{5, 10}, x);
System.out.println(bb.get(0)); //19 AYY //TO!DO: Use setSource, we don't want to wrap the native array
System.out.println(bb.get(0)); //19 AYY //TO!DO: Use setSource, we don't want to wrap the native array*/
//final int[] a={5,6,8,2,3,10,5,26,5,416,41,85,416,41};
//final int[] b={10,80,10,3,32,20,56,85,51,968,156,5894,10,60,52};
final int[] a={5,6};
final int[] b={10,80};
final int[] res=new int[a.length];
Kernel kernel=new Kernel() {
@Override
public void run() {
int i=getGlobalId();
//System.out.println(i);
res[i]=a[i]+b[i];
}
};
kernel.execute(Range.create(res.length));
System.out.println(Arrays.toString(res));
}
}