Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/08/13 in all areas

  1. Lesson 2 Introduction In this tutorial i will be explaining the basics of netbeans and its directory structure which it creates when we compile java applications. We will also be briefly touching on some concepts about java that you need to know. So first open up netbeans. Once its opened were going to make a new project. We can do this by pressing either the new project button which is orange in colour and found under the Edit tab at the top left of the window. Or you can press File then select new project. Once the new window opens we can select from the left column Java, and from the right window Java Application. Press next to move on, we now need to give the project a name and a location, i would recommend something memorable and a location such as my documents or your desktop. You will want to un-check the bottom check-box which says Create Main Class we don't need this as i will be explaining this at a later date. Then hit finish to make up your first project folder. once your window has closed back to the main window you will see you project has been created in the column on the left with the name you gave it. You can see it is in bold. if you have multiple projects you main one will be in bold so when you press compile that is the one that will be used. Next to your project name you will see a little box with a + in a square box if you click that it will show all the files inside your project. In the source files folder you wont see anything as we haven't made any yet. In the other folder called libraries will be the JDK you installed earlier, this contains all the various different files java needs that have already been made by the creators of java themselves. So to begin you want to click on the default package which is in grey and select other near the bottom of the menu. A new window will open. From the categories column select java and in the right File Type column select Java Main Class. This will hold the main method which i will explain in just a moment. Hit next to go to the next page where you need to name your Main class. I would name it Tutorial. Note it is important to use good java conventions whilst naming classes. What i mean by this is to Start each word with a Capital letter and no spaces between so 'Tutorial' or 'ThisIsMyTutorial' you can have letter, number or underscore in the name but no spaces and the classes cannoy begin with a number; letters or underscores to start is fine. Now if you open up your default package on the left you will see that your main class has been created for you and if you click on it you will see it open on the right side in the main window. Now you should abit of generated code which netbeans has kindly already pre-made for you, you can highlight all this and delete it. So now i am quickly going to go over the files that netbeans will generate for you when you create a new package, project, classes etc. If you go to the place where you created your project folder for example i saved mine on my desktop for easy access you will see in the main folder 3 other folders and 2 files. Now these hold all the different folders that your project needs to run. If you open up the src folder you will see the java main class we just created. So if you ever need to find your source files in the folder outside of netbeans you now know where they are. So now we shall begin to learn some java! the very first thing you should now is that all our code goes inside of classes. A simple analogy of this would be to look at a class as a folder. All the code must be stored within this folder so that it knows where to find it. Well how do we make a class. Type the word class into the main window and you will see it changes to a blue colour this is because class is a keyword in java , next we need to give it a name this is always the thing java will look for after you type class. A very important thing to know right now is that the name you give must be the same EXACTLY to the file name you gave your class. So from above it would be ' class Tutorial ' note the capital T. These rules regarding class names will change slightly as we learn more but for now just remember it must be the same as the file name. You will see that we have a red circle next to what we have typed so far and that's because we need to open and close our class. We do this by using pointy brackets: { When you see them being used it will be like this: class Tutorial {} When you hover over one of them in in netbeans it will highlight its partner if there is one. So now we have made a main class and named it Tutorial and we have opened and closed brackets. We refer to the area between brackets as inside of a certain area or method. Next we need to give the program a starting point else it could start anywhere. This starting point is represented by something called the main method. You might recognize it from the last tutorial and we will go over it in more detail very soon. Every single main class will have a main method with a few exceptions, it will look something like this: class Tutorial { public static void main(String [] args) { }} now when you look at the line of code i added you may think it looks really confusing and you want to quit java and thats that. Well don't it really isn't that hard at all. All's you need to know for now is that the code inside the public static void main is the code that will be executed first. Now were just going to make the most basic program possible by printing something out to the screen. Go ahead and type out the code below by yourself and make sure everything is in the right place. It's very important you learn to type it out yourself and not copy and paste. class Tutorial { public static void main(String [] args) { System.out.println("Hello World!"); }} by now i hope you have had a go at typing out the code in the box above. Lets just take a look at some of the key things you should of put in that a lot of people miss out. Make sure there is a capital S for System, make sure to use a semi colon ; after the closing bracket. A short note on semi colons. Every line of code in java that is in between those spikey brackets should have a semi colon at the end of it ( that means if your not declaring a class or method with spikey brackets ) Also make sure your using double quotes either side of Hello World. Most new java users will find remembering public static void main... and the rest of that line the hardest part. So now you have your first and very basic java program. You should be very proud of yourself! For now you don't need to know how any of the above works. I would recommend that you memorize that second line public static void main into your head, everything about it. If you can crack that as soon as possible you will be all good. I will end the tutorial by getting you to run your first program and to do that you click on the green arrow shape at the top of the screen underneath profile and team tabs. You can also press on the keyboard Shirt+F6. To see the output click on the word output at the bottom left of your window. That's it for now in the next tutorial tomorrow i will be teaching you about the basics of variables. If you liked this post please Like it using the green button to the right of this sentence
    2 points
  2. Hello everyone, i love to help out our community and as such i am willing to teach all users on the forum if they want, how to use java. I will be starting with the most basic form of java you could imagine and day by day progress to more and more advanced techniques. Below find a list of the tutorials so far: Lesson 1 - Getting Started - Post 1 Lesson 2 - Introduction - Post 2 Lesson 3 - Variables - Post 3 Lesson 1 Getting Started. In this tutorial we will be downloading the java development kit and a program called netbeans.These two things are going to allow you to jump right in and start learning Java.So the first thing you want to do is use a search engine such as google. Search for JDK the first result should be something along the lines of Java SE Downloads @ oracle.com click on that link. You will see the below: You want to click on the one that says NetBeans. ( JDK + Netbeans ) After clicking on that image/sqaure box you will come to a download page. Cick on the radio circle button that read "Accept License Agreement " then click on the appropriate installer for your operating system. Once its finished downloading its the usual installer, choose the location and accept the terms an conditions. So once you have that installed and you know it set up correctly you can move onto the next step. We will need to set up something called Environment Variables. The way were going to do this is by clicking on Start then right click on computer to bring up a menu and then click on Properties. Once a new window opens up your going to click on 'Advanced System Settings' on the left side of your new window usually the bottom option in a list of 4 or 5. Another window around half the size of the last one will open and be called System Properties. If you on windows XP you will be on the first Tab called computer name and will need to click on the tab named Advanced. Anyone on xp or above should already be on the advanced tab. So click on a button near the bottom of the advanced tab called ' environment variables ' This will open an even smaller new window. What were doing here is providing java with the path to where it was installed, this basically means that when you run a java program it knows where to find the compiler and other nice things java can do. So now leaving what we just opened aside for a moment dont close any of the windows. Click on start and click computer again. and go to the location i specify now: Computer >local disk > program files > Java > JDK 1.7? > bin. now make sure you click on program files not the x86 one and make sure if you have multiple jdk installs that you click on the latest version. If you have windows 7 you can right click on the address bar at the top and click ' copy address as text ' if you don't have windows 7 right click on any file in the bin folder and click on properties. In the general tab you will see the location of the file. You want to highlight this and copy it by either highlighting it then right clicking and selecting copy or use the short cut after highlighting it Ctrl+C Once you do that you will want to go back to your Environment variables window we opened just a moment ago and click on the New button. ( the top one ). In the variable name box type PATH in capitals. Then right click in the box called Variable Name and select paste to put in the location of the bin folder. You can then hit ok, ok, ok to close all three windows. So now that's all done we are going to test the installation of java and your Environment variables. Click on start once more and open up notepad (can be found under the Accessories folder ) Once its opened copy and paste the code below directly into notepad. Don't worry about whats going on in the code at all you will learn all this in the tutorials to come. public class Test { public static void main (String [] args) { System.out.println("Hello World!"); }} So now you should have this in your notepad file? great. Click on File at the top and select Save As. In the file name box type "Test.java" Yes do include the " " the parentheses are to make sure that the file is saved as a .java file and not as a .txt file. Just save it to your desktop for now so you can find it easily. So now you should have a little rectangle on your desktop with Test.java below it. Excellent! Now on to the next part, Press on the keyboard the windows key + R this will being up the run. Type into the open box 'cmd' without the single ' ' ' ' ' on each end. Now a big black box will come up named the command prompt. The last line in the box should say C:UsersYourUserName where YourUserName is your... you got it. We need to change the directory from your name to the desktop so type ' cd desktop ' you will see the directory change to your desktop. Now type ' javac Test.java ' the cursor will flash for a few seconds and then just show the directory once more if it has compiled correctly. What the compiler does is turn our code into a language the computer can understand and use. You will notice you have two files on your desktop now one called Test.java and now another called Test.class if you want you can open that in notepad and you will see all the weird symbols the computer uses. So now we have our .class file we can now run our program by click back onto the black cmd window and typing in ' java Test ' don't forget the capital T. We can see it now prints out Hello World! if you don't see this either because you changed the text or you get any errors or something like java does not recognized i recommend you go back and make sure you path variable is correct and your JDK is fully installed and if you get error messages such as cannot find symbol you should make sure you copied the code above exactly as i typed it with capital letters in the right place and symbols in the correct place. Thats it for this tutorial, in the next lesson we will be doing an introduction to netbeans and going over the very basics of java. Like this post if you followed it fine or liked what you read so far. i will post the next one tomorrow
    1 point
  3. Hi all, Just a heads up on what we have been doing since the release of the public BETA: We have fixed the issue with the low FPS. It now runs smoothly. We also have made the client and server more secure. Another important thing we did is we added another layer to our hook updater to make them even more reliable. Our hooks are very reliable already, but this feature is one that will improve it even further. Furthermore, we have made a nice script that will help us to release OSBot features more easily. It compiles, obfuscates, changes the version numbers to the required values. For the future we will also create a script that will automatically check for revision updates and run the hook updater on the server automatically on the event. We have made a list of bugs you reported, features that are missing (we had most of them already on our todo list) and overall polishing related tasks. We are hunting them down one by one. Please stay tuned! OSBot.org
    1 point
  4. Update log: Improved security for server and client authentication Fixed username bugs with spaces for server and client authentication Changed server and client authentication to use LOGIN name instead of DISPLAY name Solved issue with low FPS. FPS now caps on 50 as normal Issues with high CPU and memory have been resolved partially, we profiled the client and it's now mainly the runescape client itself. It could be that your process displays more than 250mb - 300mb, but that's the allocated space by the JVM which we will add a manifest for in the future in the jar to make the JVM allocate just what it needs. As for the CPU, there will be coming more optimizations in the near future, but it should already run noticeably lower. Make sure you clear your browsers cache if the download on the main page gives you the same jar you already had. We will make sure that we change the way your browser cache it in the future. Stay tuned for the next update, OSBot.org
    1 point
  5. Driver and co: I LITERALLY said what to do in case you download the same version: Clear browser its cache ;)
    1 point
×
×
  • Create New...