🔒 Locked
[java] Old C++ Programmer, new to Java... need help on basics
Advertisement
Original Post
Hey, so I''m checkin java out and I''m like, "whoa, this is cool i can actually write a program and put it in a browser" not to mention the fact that I can grasp the language quickly seeing that it''s mostly C++ syntax. Also I have gotten stuck and need help. This is probably very basic but hell, i haven''t figured it out hehe
I don''t know how to read and write from a file using an Applet. I know there''s some kind of restriction or something and you need to create some policy permission or something. Could someone help a newbie to java.
From what I have read, it''s impossible to write to/read from the file system in an Applet. I''m only using Java 1.2 though, maybe that has changed with your version (which is what, by the way?)... full Java applications should not have this limitation however.
Another limit I found was menus (no menus in Applets, which really sucks).
I''m using Java 1.1 Programming in 21 Days (a little old, but from my college days), which I really find is a good reference/tutorial book since I am very familiar with multiple languages already (primarily with C++).
I have a project I am working on, using a compliment of Java (client) and C++ (server) ... email me if you''d like to know more.
MatrixCubed
http://MatrixCubed.cjb.net
Another limit I found was menus (no menus in Applets, which really sucks).
I''m using Java 1.1 Programming in 21 Days (a little old, but from my college days), which I really find is a good reference/tutorial book since I am very familiar with multiple languages already (primarily with C++).
I have a project I am working on, using a compliment of Java (client) and C++ (server) ... email me if you''d like to know more.
MatrixCubed
http://MatrixCubed.cjb.net
If the applet is bundled in a .jar file it can access files in the same .jar as itself. Also it should be able to access files on the server it comes from. Have a look into AppletContext for more information on this.
-Neophyte
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GED d- s:+ a- C++$ UL++ P++ L++ E W+ N+ o K? w !O M--(+) V-- PS+
PE Y+ PGP t-- 5++ X+ R(+) rv+(++) b+++ DI+ D(+) G e+>++ h r--> y+
----- END GEEK CODE BLOCK-----
geekcode.com
-Neophyte
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GED d- s:+ a- C++$ UL++ P++ L++ E W+ N+ o K? w !O M--(+) V-- PS+
PE Y+ PGP t-- 5++ X+ R(+) rv+(++) b+++ DI+ D(+) G e+>++ h r--> y+
----- END GEEK CODE BLOCK-----
geekcode.com
its as always: it depends...
in case you want to have people to load your applet
from your internet webserver, there is no other way than to sign
your applet's jar-file. after signing your applet can
do everything (the user will still be prompted to
trust the applet on startup).
in case you want to run your applet only locally or on
an intranet where you have control over the user's
computers, you can use the policytool coming along
with the jre, or you can manually edit the policyfile.
as a starting point, look for the file
/lib/security/java.policy and insert
the following block:
grant {
permission java.security.AllPermission;
};
this gives your applet on your own machine ALL permissions, so
you can play around and test your applet.
but be very careful with this change: every applet from
the internet also has FULL access to your machine! so make
sure you remove these lines before accessing the internet.
for more details on this topic take a look here
http://java.sun.com/sfaq/
http://java.sun.com/docs/books/tutorial/
here is another one on signing jars:
http://java.sun.com/products/plugin/1.2/docs/nsobjsigning.html
[edited by - Heliosphere on May 25, 2002 6:55:19 AM]
in case you want to have people to load your applet
from your internet webserver, there is no other way than to sign
your applet's jar-file. after signing your applet can
do everything (the user will still be prompted to
trust the applet on startup).
in case you want to run your applet only locally or on
an intranet where you have control over the user's
computers, you can use the policytool coming along
with the jre, or you can manually edit the policyfile.
as a starting point, look for the file
the following block:
grant {
permission java.security.AllPermission;
};
this gives your applet on your own machine ALL permissions, so
you can play around and test your applet.
but be very careful with this change: every applet from
the internet also has FULL access to your machine! so make
sure you remove these lines before accessing the internet.
for more details on this topic take a look here
http://java.sun.com/sfaq/
http://java.sun.com/docs/books/tutorial/
here is another one on signing jars:
http://java.sun.com/products/plugin/1.2/docs/nsobjsigning.html
[edited by - Heliosphere on May 25, 2002 6:55:19 AM]
to read from files from the server you do it the normal way just like in applications. to write to a file you have to write a server app that has to be running on the host. from the applet you then send the information to the server and tell it to write to a file.
it''s a bit stupid but that is the way things work.
_______________________
http://mill.3dfxsweden.net
it''s a bit stupid but that is the way things work.
_______________________
http://mill.3dfxsweden.net
Yea, it does seem kinda stupid hehe... Well, I think i figured it out. I wrote an applet that talks to a CGI script just now and it write up the information that the Applet gives it. Hopefully I can re-write it in a class and give out the source code.
I''ll try to do that tonight.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement