Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Download: http://www.mediafire.com/download/bd38k4m84luxydk/JAVA+PS3Lib+JNI4NET+TUT.zip
- //Download includes: Source files, tutorial + files, Pre-compiled and ready to use files
- ###############################################
- ###JAVA PS3LIB -> C# TUTORIAL By: BaSs_HaXoR###
- ### (11/13/14) ###
- ###############################################
- ##################################################################################################################################
- You need Java JDK (x64 preferrably) or (x32 if you don't have a 64-bit operating system) in order to continue!
- ##################################################################################################################################
- 1: Open CMD (Command Prompt) as ADMINISTRATOR!
- //DONT CLOSE OUT OF CMD THROUGHOUT THE TUT... you will need it.
- ----------------------------------------------------------------------------------------------------------------------------------
- //You may replace C:\ with the output directory of your choice...
- 2: Type "Proxygen.exe PS3Lib.dll -wd C:\
- //This is a MODIFIED PS3LIB! Not any PS3Lib will work!
- ----------------------------------------------------------------------------------------------------------------------------------
- 3: Go to the ouput directory, their should be files at the root of it called: "clr", "jvm", "build.cmd", and "PS3Lib.proxygen.xml".
- ----------------------------------------------------------------------------------------------------------------------------------
- 4: Right Click on the build.cmd and open with notepad. Find where it says "csc" in the file (17th line) and replace it with "C:\WINDOWS\Microsoft.NET\Framework\v3.5\csc.exe".
- //SAVE IT, and then you can then close the file.
- ----------------------------------------------------------------------------------------------------------------------------------
- 5: Now that you have done that, you have to COPY ALL FILES IN THE ROOT -> the following: clr folder, jvm folder, build.cmd and ps3lib.proxygen.xml <- and paste them
- into "C:\Program Files\Java\jdk1.7.0_45\bin\" or wherever your Java JDK is located.
- ----------------------------------------------------------------------------------------------------------------------------------
- 6: Back to CMD, run the following commands:
- (echo is on at this point, keep it on)
- "cd \" (This will take you to the root of your main Drive)
- "cd --" (replace -- with the location of your JDK\bin directory) (example-> cd C:\Program Files\Java\jdk1.7.0_45\bin\)
- "build.cmd" (This will run the .batch file (the one you modified in step '4'), and compile the classes to "target\classes\ps3lib\"
- and will compile the fully functional ".dll" and ".jar" to the root of your "bin\" directory and be available for Java to run your C# code.
- //ps3lib.j4n.dll is compiled from the "clr" folder
- //ps3lib.j4n.jar is compiled from the "jvm" folder
- /*<<< The compiled files should be named: "PS3Lib.j4n.jar" and "PS3Lib.j4n.dll" >>>*/
- ----------------------------------------------------------------------------------------------------------------------------------
- 7: Now that you have successfully compiled the files, take them and put them into a folder that doesn't require ADMINISTRATOR Privelages (C:\program files\... does)
- //Example: "C:\New Folder\" or a folder on your desktop would work fine. Again, anywhere that doesn't require admin privelages to (I/O) Read/Write.
- ----------------------------------------------------------------------------------------------------------------------------------
- 8: Go into 'Eclipse' or any JAVA IDE (ex. Netbeans, Eclipse, etc).
- ----------------------------------------------------------------------------------------------------------------------------------
- 9: Create new project. (In Eclipse: File>New>Java Project) and for example, lets name it "myPS3JavaExample"
- ==================================================================================================================================
- 9a): (In Eclipse) Right Click on the project root (the name "myPS3JavaExample")> Properties > Java Build Path. And then click: Add External JARs... and select "PS3Lib.j4n.jar".
- Click "Add External JARs" for a second time, and choose the "jni4net.j-0.8.8.0.jar" file, which is need for your PS3lib.j4n.jar to work.
- 9b): (In Eclipse) Go to the folder "COMPILE YOURSELF\Files needed for Eclipse (or other IDE)" and drag all of them onto your project
- package name "myPS3JavaExample".
- You should get a popup: "Select how files should be imported into the project:" Select "Copy files", and click "OK".
- ==================================================================================================================================
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 10) Now that you have added the .jar files to you project, you should now see them in the "Refrenced Libraries dropdown in Package Explorer.
- Add the following to you Main.java project:
- //Put this at the very top of your java code
- import java.io.File;
- import net.sf.jni4net.Bridge;
- import ps3lib.CCAPI;
- import system.io.IOException;
- //Put this at the very top of your java code
- //Your java project should have similar strucure as the one below... Just add the code within the void main(String[] args).
- //(Just copy everything from try to the last catch "}" and put it in your project.
- public class JavamyPS3 {
- /**
- * @param args
- */
- public static void main(String[] args) {
- //COPY everything from here...<<
- try
- {
- Bridge.setVerbose(true);
- Bridge.init();
- Bridge.LoadAndRegisterAssemblyFrom(new File("LocationTo\YourPS3Lib\forJava\PS3Lib.j4n.dll"));
- //ex. Bridge.LoadAndRegisterAssemblyFrom(new File("C:/Development/DEV/ass/JavPs3/src/PS3Lib.j4n.dll"));
- ps3lib.CCAPI ps3 = new ps3lib.CCAPI();
- ps3.BaSs_HaXoRwazHere();//this will open a windows from from C# if it works.
- }
- // TODO Auto-generated method stub
- catch (java.io.IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- //>>to here.
- }
- }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 11) Now you should be able to debug/run your project. I get errors, maybe you'll be lucky.
- //Tip: You may try recoding/reformatting (Modify) the PS3Lib.dll and compile it again to see if you can get it working that way.
- //Also you may try using this method for PS3TMAPI_NET.dll (I get errors, you will have to modify TMAPI to work with the proxygen.exe class creator
- and java compiler.
- THATS IT! ....
- ---------------------------------------------------------------------------------------------------------------------------------
- Credits to: BaSs_HaXoR, Developer(s) of JNI4NET, Developer(s) of Eclipse, ALL the tuts on JNI4NET, and of course Java
- ---------------------------------------------------------------------------------------------------------------------------------
- Helpful links:
- # 1) https://www.youtube.com/watch?v=XKEpcsvl1Q8&channel=mendoza10tube
- # 1) https://stackoverflow.com/questions/9283040/eclipse-android-project-how-to-reference-library-within-workspace
- //I used this for 'csc.exe' -> https://stackoverflow.com/questions/3425515/c-sharp-beginner-compiling-from-command-line
- #) https://stackoverflow.com/questions/25997188/getting-java-lang-unsatisfiedlinkerror-no-sapjco3-in-java-library-path-error
- #) http://www.coderanch.com/t/377174/java/java/java-library-path
- #) http://zamboch.blogspot.cz/2009/11/how-calling-from-java-to-net-works-in.html
- #) http://jni4net.com/
- #) https://github.com/jni4net/jni4net/wiki/Generating-Proxies
- #) https://github.com/jni4net/jni4net/wiki/Calling-C%23-in-Java
- #) http://zamboch.blogspot.cz/2009/10/jni4net-bridge-jvm-and-clr.html
- #) http://zamboch.blogspot.cz/2009/11/how-calling-from-java-to-net-works-in.html
- #) https://searchcode.com/?q=java%20lang%3AC%23%20source:GoogleCode
- #) http://www.codeproject.com/Articles/378826/How-to-wrap-a-Csharp-library-for-use-in-Java
- ---------------------------------------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement