applet troubles (wanna try C/C++)

Started by
44 comments, last by alexxzius 16 years, 9 months ago
wow that must be a record for one phrase to be quoted and trashed. . .
Ive used pointers before so I know a few things. They may be fast, but only in execution sense. They clog up the program which makes it hard to program.
*(list+indx)->data[0]=5; // make me wonder what the?
I might as well program entirely in assembly to make it even more faster.
Correct me if im wrong but Java dont have pointers and it dont miss it a bit. (except u cant write viruses in Java)

Maybe its wrong for me to assume that C/C++ is a memory hog, but from past experience my programs crashed when i had an array of more than 300 ints.

About portability: even after installing every java utility from sun i still cant execute jar files. Maybe jars work on cell-phones, mp3 players and calculators but unless they work on PC's they kinda usless. (Dont quote its just an assumption ;)
And i seen .exe files in my Dev-C directory without linking anything (if only java could do that . . .)

Ok, i assume that the answer is NO. Fine. Forget C/C++ then.
Since all ya experts in like every language, can u give me some advice on how to make my browser run jar files. I created the jar file, put it next to my .htm page like the tutorial said.
...
<applet code=applet1.class archive=applet1.jar width=500 height=300>
...

and it gives me a bunch of Unknown Source errors. Help apreciated. ;)
[[This thread can be found in java development forum. I suppose this forum is more active since i get like 1 responce a week in Java forums.]]
Advertisement
Was the ramble part generated using a Markov chain?

The words are correct, so are short fragments, but they have no context, and they are all absurdly incorrect or make no sense.
that was to warn light-hearted people. Guess it didnt work . . .
If u dont understand a thing i said, forgive my russian potomu chto ya ploho govoryu po angliyski. Mne ochen nuzhna pomosh.

Need to execute my jars.
Quote:Original post by alexxzius
wow that must be a record for one phrase to be quoted and trashed. . .
Ive used pointers before so I know a few things. They may be fast, but only in execution sense. They clog up the program which makes it hard to program.
*(list+indx)->data[0]=5; // make me wonder what the?
I might as well program entirely in assembly to make it even more faster.
Correct me if im wrong but Java dont have pointers and it dont miss it a bit. (except u cant write viruses in Java)


Yes, pointers do make C (and C++) a hard language to learn. Just because they are difficult to comprehend doesn't make them pointless; they're what make C such as an excellent language for low-level programming.

Quote:Original post by alexxzius
About portability: even after installing every java utility from sun i still cant execute jar files. Maybe jars work on cell-phones, mp3 players and calculators but unless they work on PC's they kinda usless. (Dont quote its just an assumption ;)


.jar files can definitely run on a PC. How are you executing them?

Quote:Original post by alexxzius
Ok, i assume that the answer is NO. Fine. Forget C/C++ then.
Since all ya experts in like every language, can u give me some advice on how to make my browser run jar files. I created the jar file, put it next to my .htm page like the tutorial said.
...
<applet code=applet1.class archive=applet1.jar width=500 height=300>
...


This thread might be able to help.
Quote:Original post by alexxzius
Correct me if im wrong but Java dont have pointers and it dont miss it a bit


Java does actually have pointers it's just under the hood. everything in java is pass by reference by default which is like passing by pointer. Java doesn't give you direct access to freeing memory but again it does it all under the hood.

Quote:Original post by alexxzius
Maybe its wrong for me to assume that C/C++ is a memory hog, but from past experience my programs crashed when i had an array of more than 300 ints.


That's because you are allocating the array on the stack instead of the heap. In C you are generally limited to 2MB of stack memory by the OS. In java, arrays are automatically created on the heap. The correct way to allocate a big array in C:

int *myArray = new int[300];//and when you're donedelete[] myArray;


Again under the hood, that's what Java does when you allocate an array.

Quote:Original post by alexxzius
About portability: even after installing every java utility from sun i still cant execute jar files. Maybe jars work on cell-phones, mp3 players and calculators but unless they work on PC's they kinda usless. (Dont quote its just an assumption ;)


Of course you can execute jars on a PC. you just haven't taken the time to read the documentation. The above poster has a link you should read.

Quote:Original post by alexxzius
And i seen .exe files in my Dev-C directory without linking anything (if only java could do that . . .)


The entire purpose of Java is so that it never has to generate an exe. A .exe file is only for windows. It will not run on: *nix, Mac or any other operating system without emulation. .jar runs in a java virtual machine. there are VMs available for almost every platform out there which makes the .jar format extremely powerful because it does not need to be re-compiled to run on another platform. It makes it a little tricky to run (you have to properly set up an execution environment) but that's the tradeoff for portability.

Quote:Original post by alexxzius
Ok, i assume that the answer is NO. Fine. Forget C/C++ then.
Since all ya experts in like every language, can u give me some advice on how to make my browser run jar files. I created the jar file, put it next to my .htm page like the tutorial said.
...
<applet code=applet1.class archive=applet1.jar width=500 height=300>
...

and it gives me a bunch of Unknown Source errors. Help apreciated. ;)
[[This thread can be found in java development forum. I suppose this forum is more active since i get like 1 responce a week in Java forums.]]


No you didn't. You made a normal jar not an applet. To run java in a browser you need to specifically author an applet, not just a normal java application. How to author an applet:
http://java.sun.com/applets/

You really need to stop thinking that you already know all the answers. You know very little (which is totally fine and completely expected for a beginner). You are crippling your learning process by expecting that everything is simple. Programming is hard and takes a month or so before all the building and running of applications becomes 2nd nature.

-me
thanx for the reply. I had the same problems with running applets (not jars). I solved it by running an apletviewer once which somehow (?) made my browser display applets which it couldnt do before.
The thread didnt help much cause im executing my jars from my hard drive, not from the internet. Guess thats different. And my JRE and JDK are of the same release...

A question: u normally cant run jars just by clicking on them, can u? I did and it gave me an error which said that a binary was missing or something...

Quote:Original post by alexxzius
A question: u normally cant run jars just by clicking on them, can u? I did and it gave me an error which said that a binary was missing or something...


I think with some Java VMs you can just double-click jars. It may be a configuration issue. It's been a long time since I've programed client-side java so I don't really know for sure.

-me
Quote:
int *myArray = new int[300];
//and when you're done
delete[] myArray;


again pointers. Thats why i switched to java

Quote:
No you didn't. You made a normal jar not an applet. To run java in a browser you need to specifically author an applet, not just a normal java application. How to author an applet:
http://java.sun.com/applets/


could u be more specific. This entire section is about applets, which i downloaded and read. I seem to have missed a section on how to author an applet.

Quote:
You really need to stop thinking that you already know all the answers. You know very little (which is totally fine and completely expected for a beginner). You are crippling your learning process by expecting that everything is simple. Programming is hard and takes a month or so before all the building and running of applications becomes 2nd nature.


If i knew everything i wouldnt be asking. And its this way with java: there is no good concise help file on java with search feature and examples (like with c/c++), so u gotta guess a lot of stuff or ask others.
This may be a better look into java applets.

C++: A Dialog | C++0x Features: Part1 (lambdas, auto, static_assert) , Part 2 (rvalue references) , Part 3 (decltype) | Write Games | Fix Your Timestep!

Original post by Palidine
The correct way to allocate a big array in C:
int *myArray = new int[300];//and when you're donedelete[] myArray;



Nope, that's C++. In C, you'd do
int* myArray = malloc(sizeof(int) * 300);//and when you're donefree(myArray);

This topic is closed to new replies.

Advertisement