Advertisement
BaSs_HaXoR

Compiled JAVA PS3Lib (JNI4NET)

Nov 13th, 2014
499
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.18 KB | None | 0 0
  1. Download: http://www.mediafire.com/download/bd38k4m84luxydk/JAVA+PS3Lib+JNI4NET+TUT.zip
  2. //Download includes: Source files, tutorial + files, Pre-compiled and ready to use files
  3. ###############################################
  4. ###JAVA PS3LIB -> C# TUTORIAL By: BaSs_HaXoR###
  5. ### (11/13/14) ###
  6. ###############################################
  7.  
  8. ##################################################################################################################################
  9. You need Java JDK (x64 preferrably) or (x32 if you don't have a 64-bit operating system) in order to continue!
  10. ##################################################################################################################################
  11. 1: Open CMD (Command Prompt) as ADMINISTRATOR!
  12. //DONT CLOSE OUT OF CMD THROUGHOUT THE TUT... you will need it.
  13. ----------------------------------------------------------------------------------------------------------------------------------
  14. //You may replace C:\ with the output directory of your choice...
  15. 2: Type "Proxygen.exe PS3Lib.dll -wd C:\
  16. //This is a MODIFIED PS3LIB! Not any PS3Lib will work!
  17. ----------------------------------------------------------------------------------------------------------------------------------
  18. 3: Go to the ouput directory, their should be files at the root of it called: "clr", "jvm", "build.cmd", and "PS3Lib.proxygen.xml".
  19. ----------------------------------------------------------------------------------------------------------------------------------
  20. 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".
  21. //SAVE IT, and then you can then close the file.
  22. ----------------------------------------------------------------------------------------------------------------------------------
  23. 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
  24. into "C:\Program Files\Java\jdk1.7.0_45\bin\" or wherever your Java JDK is located.
  25. ----------------------------------------------------------------------------------------------------------------------------------
  26. 6: Back to CMD, run the following commands:
  27. (echo is on at this point, keep it on)
  28.  
  29. "cd \" (This will take you to the root of your main Drive)
  30. "cd --" (replace -- with the location of your JDK\bin directory) (example-> cd C:\Program Files\Java\jdk1.7.0_45\bin\)
  31. "build.cmd" (This will run the .batch file (the one you modified in step '4'), and compile the classes to "target\classes\ps3lib\"
  32. 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.
  33. //ps3lib.j4n.dll is compiled from the "clr" folder
  34. //ps3lib.j4n.jar is compiled from the "jvm" folder
  35.  
  36.  
  37. /*<<< The compiled files should be named: "PS3Lib.j4n.jar" and "PS3Lib.j4n.dll" >>>*/
  38.  
  39. ----------------------------------------------------------------------------------------------------------------------------------
  40. 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)
  41. //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.
  42. ----------------------------------------------------------------------------------------------------------------------------------
  43. 8: Go into 'Eclipse' or any JAVA IDE (ex. Netbeans, Eclipse, etc).
  44. ----------------------------------------------------------------------------------------------------------------------------------
  45. 9: Create new project. (In Eclipse: File>New>Java Project) and for example, lets name it "myPS3JavaExample"
  46. ==================================================================================================================================
  47. 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".
  48. 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.
  49.  
  50. 9b): (In Eclipse) Go to the folder "COMPILE YOURSELF\Files needed for Eclipse (or other IDE)" and drag all of them onto your project
  51. package name "myPS3JavaExample".
  52. You should get a popup: "Select how files should be imported into the project:" Select "Copy files", and click "OK".
  53. ==================================================================================================================================
  54.  
  55. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  56. 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.
  57.  
  58. Add the following to you Main.java project:
  59.  
  60. //Put this at the very top of your java code
  61. import java.io.File;
  62. import net.sf.jni4net.Bridge;
  63. import ps3lib.CCAPI;
  64. import system.io.IOException;
  65. //Put this at the very top of your java code
  66.  
  67. //Your java project should have similar strucure as the one below... Just add the code within the void main(String[] args).
  68. //(Just copy everything from try to the last catch "}" and put it in your project.
  69.  
  70. public class JavamyPS3 {
  71.  
  72. /**
  73. * @param args
  74. */
  75. public static void main(String[] args) {
  76.  
  77. //COPY everything from here...<<
  78. try
  79. {
  80. Bridge.setVerbose(true);
  81. Bridge.init();
  82. Bridge.LoadAndRegisterAssemblyFrom(new File("LocationTo\YourPS3Lib\forJava\PS3Lib.j4n.dll"));
  83.  
  84. //ex. Bridge.LoadAndRegisterAssemblyFrom(new File("C:/Development/DEV/ass/JavPs3/src/PS3Lib.j4n.dll"));
  85.  
  86. ps3lib.CCAPI ps3 = new ps3lib.CCAPI();
  87. ps3.BaSs_HaXoRwazHere();//this will open a windows from from C# if it works.
  88. }
  89.  
  90. // TODO Auto-generated method stub
  91. catch (java.io.IOException e) {
  92. // TODO Auto-generated catch block
  93. e.printStackTrace();
  94. }
  95. //>>to here.
  96. }
  97.  
  98. }
  99. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  100. 11) Now you should be able to debug/run your project. I get errors, maybe you'll be lucky.
  101. //Tip: You may try recoding/reformatting (Modify) the PS3Lib.dll and compile it again to see if you can get it working that way.
  102.  
  103. //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
  104. and java compiler.
  105.  
  106. THATS IT! ....
  107. ---------------------------------------------------------------------------------------------------------------------------------
  108. Credits to: BaSs_HaXoR, Developer(s) of JNI4NET, Developer(s) of Eclipse, ALL the tuts on JNI4NET, and of course Java
  109. ---------------------------------------------------------------------------------------------------------------------------------
  110. Helpful links:
  111. # 1) https://www.youtube.com/watch?v=XKEpcsvl1Q8&channel=mendoza10tube
  112. # 1) https://stackoverflow.com/questions/9283040/eclipse-android-project-how-to-reference-library-within-workspace
  113. //I used this for 'csc.exe' -> https://stackoverflow.com/questions/3425515/c-sharp-beginner-compiling-from-command-line
  114. #) https://stackoverflow.com/questions/25997188/getting-java-lang-unsatisfiedlinkerror-no-sapjco3-in-java-library-path-error
  115. #) http://www.coderanch.com/t/377174/java/java/java-library-path
  116. #) http://zamboch.blogspot.cz/2009/11/how-calling-from-java-to-net-works-in.html
  117.  
  118. #) http://jni4net.com/
  119. #) https://github.com/jni4net/jni4net/wiki/Generating-Proxies
  120. #) https://github.com/jni4net/jni4net/wiki/Calling-C%23-in-Java
  121. #) http://zamboch.blogspot.cz/2009/10/jni4net-bridge-jvm-and-clr.html
  122. #) http://zamboch.blogspot.cz/2009/11/how-calling-from-java-to-net-works-in.html
  123. #) https://searchcode.com/?q=java%20lang%3AC%23%20source:GoogleCode
  124. #) http://www.codeproject.com/Articles/378826/How-to-wrap-a-Csharp-library-for-use-in-Java
  125. ---------------------------------------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement