Java rectangles for collision? [solved]

I have been using rectangles for collision since i have started making “games” in java, but they are not working i have trued everything to make it work and it doesn’t! So is there any other way of collision in java? I don’t mean collision detection i mean like player cannot pass throu walls and stuff like that! I have been getting the collision and making a rectangle out of it and i take it width and subtract it of the player x, repeat for y! I get player shaking out of the rectangle. Need help!