• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

Unable to run self-made Java programs

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

mt1000

Registered
Joined
Feb 5, 2015
I have a different problem with Windows 7 (64 bit) and JAVA 8.

I am learning JAVA and lessons are going fine. I have used and installed applets on websites before with no problem. Now I would like to learn to write my own applets.
I am using JAVA's latest utility because they say to. I have Net Beans and they also say to use the new version.
The JAVA verify page shows I have it installed and other pages with JAVA show correctly on my browser.
I do not have 'old' versions of JAVA on my computer.
I have done the uninstall and re-install trick.
I tried Firefox, IE browser switch.
I have re-booted, scanned for viruses etc. etc.

What I am getting with a very simple applet (just shows a math problem with addition) is an HTML page that correctly shows the grey box in specified dimensions and the JAVA Alert Box telling me my computer security settings prevent the applet from showing. :-/
I looked up this problem and tried several solutions to no avail.

One solution offered by Oracle is to go to the JAVA control panel and change the security setting.
But JAVA 8 only has 2 settings - "high" and "super-high". I don't have an option for "medium".

There is an option on the control panel to import a security certificate / signature. It wants one with .crt or .p12 extension.

When I look all over in C:\ I can find no such thing. I'd like to get one. Any one. I just want this thing to show up so I can get on with my lessons. I know some JAVA lingo but I am bewildered by security jargon.

Any help at all would really be appreciated. ;) There has to be a way of seeing your own work on your own computer with JAVA 8!
 
mt1000, since the thread you posted in was related to java crashing and you don't have that issue, I moved your post to a new thread. You will get better answers here.
 
Thanks! And good headline. Let's hope for a nibble!:p
 
You'll need to either lower the security settings, add the site your applet is hosted on to your exception list, or just break down and sign your applet.

Take a look through the documentation on signing jars to better understand it:
http://docs.oracle.com/javase/tutorial/deployment/jar/signing.html
https://www.owasp.org/index.php/Signing_jar_files_with_jarsigner

Basically you'll need to use the keytool utility to generate a keystore, then use the jarsigner utility to sign your applet with that key.
 
Thanks! I'll try that. I came across that key tool thing when I was looking for a dot crt file.
 
I need to point out that applets are dead and gone, only outdated sites written years ago still use them, and you'd have to be crazy to let your browser launch one. Too many security issues. I suppose it's fine as an academic exercise, but you're probably better off learning Java EE instead :)
 
ugh oh --- JAVA EE (????)
The reason I was trying to learn JAVA is I got stuck in the mud with C++ and was trying to backtrack.
OK. At least it's not me.
I will look it up.

Meanwhile ....here is some h*ll they put me through ....

-------------------------------------------------------------------------------

Well maybe this JAVA 8 is for people who run LINUX and not Windows.

I jumped through all the hoops to do the signature thing.
[ http://docs.oracle.com/javase/tutorial/deployment/jar/signing.html etc. ]
I get a black command RUN box to appear but it doesn't accept anything I type then it disappears.
I know from C++ when you get that box it blinks out unless you add a line
system ("pause") ;
but what do I know.

So then I think maybe if I just go retro with earlier version of JAVA with 'old' security settings I can proceed.

I unstalled everything.
I reinstalled JDK 7u72 [No Good]
uninstall
" "71 [corrupt file]
uninstall

" "67 [No Good]
uninstall
Re-install JAVA 8 and the verify page says it is good.

BUT... it won't show my (C:\ ) local file applet.


I added my url to the exceptions list in the JAVA Control Panel (rockythedog.net).
I put the applet on line to try that and it won't show. On line it says it can't find the class file when it certainly is there in the same folder as the html.
http://www.rockythedog.net/PEN/TRY3.html
http://www.rockythedog.net/PEN/2/TRY4.html

Here is part of what the Oracle log says on the local file try:

"basic: Your security settings have blocked a local application from running
basic: Dialog type is not candidate for embedding
basic: exception: Your security settings have blocked a local application from running.
com.sun.deploy.security.BlockedException: Your security settings have blocked a local application from running
at com.sun.deploy.security.BlockedDialog.show(Unknown Source)"
... a lot of text ...
"security: Reset deny session certificate store
basic: Removed progress listener: sun.plugin.util.ProgressMonitorAdapter@1d1916b
security: Reset deny session certificate store"


Here is part of what the Oracle log says on the online try:

"basic: Your security settings have blocked a local application from running
basic: Dialog type is not candidate for embedding
basic: exception: Your security settings have blocked a local application from running."
It says about the same even though I put my url (with the slash at the end) in the exceptions list.
I thought that would get it to go but it's still blocked.
My url does show other JAVA embedded pages.

---------------------------------------------------

Back to the drawing board . . . :sly:
 
What exactly are you trying to get the java application to do?
Is this running in a browser as JSP, Java EE, or as an Applet; or does it run as a Client windowed application?

Also, as it sounds like you are taking classes on it. Have you considered asking your instructor?
 
I get a black command RUN box to appear but it doesn't accept anything I type then it disappears.
I know from C++ when you get that box it blinks out unless you add a line
system ("pause") ;
but what do I know.

I'll start with this one.

What's happening is that you've apparently fashioned a text mode application (like a C++ console app, only in Java instead). There's no GUI. That's fine, but here's where your problem is. A text mode application runs in a command window (some still call that a DOS window). It's a commad line OS prompt for executing text only (console) applications. There's no problem with that, but if you execute such an application from within Windows, like double clicking an EXE that's a console application, the console opens, the application runs, then finishes, then the console window closes.

The "pause" solution is simply a way to hold the last step...keeping the window open so you can see what it may have written as text before the window closes.

A better solution, in my view, is to execute such commands by first opening a command window, which stays. Then, navigate as required and execute the console application by typeing it's name. It will execute, finish, and then...return to the command prompt instead of closing the window.

As to a few other points:

It's much easier to learn Java. C++ is my favorite and primary language of choice, but it's nasty. It's full of all kinds of pitfalls only experienced programmers can deal with. It's the choice for high performance application development. It is not a good choice for learning without a full out commitment to learning the language. Java avoids most of the pitfalls and complications.

The difference is that C++ is built on C, which was originally intended as a kind of CPU independent assembler with higher level features. It can be among the most efficient language choices you can make, but you're exposed to much of the "RAW machine like" behavior of the CPU. Java has no such aim. It uses a related syntax of course, but is intended for application development and ease of teaching / learning. C's first purpose was to write an operating system.

That said, you're still going to face similar application level learning, like that of the command line application paradigm mentioned earlier.

Java isn't intended for Linux. Your statement might apply to a version of Java intended for installation on Linux vs Windows, but I assure you the installers keep that from getting mixed up. Java is intended to be OS independent. There is considerable debate about application independence of platform or CPU, especially given the native interfaces (for OS and CPU) available.

It's clear you're just starting out, and my advise is to be patient. Proceed knowing you'll be confused for a while, but that subsides. There is a certain minimum amount of overall knowledge you must accumulate before you'll find yourself understanding these puzzles, and you're going to be bumping into walls like this for quite a while. Let that be the norm that it is. It fades eventually.

Like others have said, putting a Java app inside a web page is a defunct concept, but more to the point, it's also more work than learning Java. It's a hint that you're leaping too far into one direction (that of packaging an applet for the web) without having first learned the fundamentals. That's the reason for suggesting Java EE. What you need first is a general Java development environment.

Only after you have some experience with GUI applications in Java would it be appropriate to attempt putting such an application inside a web page.

The point being made about Java applets is in light of the fact that in modern browsers, Javascript has been used with sufficient results to obviate most needs for Java applets, as they once existed. Java applets offer more power, speed and flexibility, but at considerable cost to the user in time to install / setup Java, the security concerns of running a Java applet and the overall download density of doing that. It's only appropriate for highly ambitious web page targets where the power of Java is required to achieve the goal. That's rarely a good idea, its' been realized, because if the task is beyond Javascript, it's probably best as a standalone application rather than part of a web page. Exceptions exist but are rare.

The subject you're approaching has several parts. You need to focus on the language at this point. You've been caught up in another related subject entirely, that of installing or executing applications.

From within a debugger, if you execute a console application (text mode only), you're going to get a console window which will close when the application completes, just as you described.

However, running the application from the command prompt eliminates the debugger, so you can't follow the application from inside.

Two simple solutions exist. One, set a breakpoint at the start and the end of the application. That's the equivalent of a pause command as you mentioned before, but runs in the debugger.

Second, you can write the application so it waits at startup for some command or keystroke. Start it in the command window, then while it's waiting, use the debugger to "attach" to it.

You'll need to read about how such things are done. I've already gone on way too much, as patience limitations from other members have shown me.

If you're comfortable with your IDE, debugger and OS environment, there's little reason to reconsider it, so take the following lightly and skeptically.

Visual Studio on Windows installs and works with little effort. It functions as you'd expect, and documentation on "how to" write software using it usually works exactly as you expect.

What you've experienced this far is the more complicated challenge of setting up a Java development environment. Further, documentation and "how to" books have to be written with the assumption that students / users could be on Mac, Linux or Windows. This means much of the material relating to IDE configuration issues, behavioral quirks, OS specifics...are all left up to you, and are in separate texts or references.

The only problem is, Visual Studio doesn't really "do" Java. It's focused on C#, C++ and J# (the .NET languages).

Visual Studio and C# is so well documented by third parties, and functions in such expected ways, that fewer surprises are in store for those who chose that path. I loathe C# myself, and it's certainly not Java. It does have a similar level of placement, as a language, but is more Windows centric (there is a Linux and MAC target option, but using it on those platforms is a lot like using Java in Windows...complicated). Certainly Java allows one to targate Android, while C# is highly limited in the mobile target space.

Both have a C++ related syntax, and both have benefits. C# is more native with Windows (very native, in fact)...Java is not.
 
Last edited:
Thanks for the detailed reply. I need all of that info.
I maybe put the horse before the cart with C++.
I am interested in learning more about C++ and JAVA because I really like Java Script and want to go on to the 'next' step. I do Java Script but don't really understand how it works. And what I did so far in other languages has been helpful.

I'm a fan of ANFY* applets so that's how I took that turn in the road.
I will go back to my text book (Visual Quickstart) and just plod along til I finish the book and re-try your suggestion with GUI etc.
Waiting in the wings I have JAVA EE and GlassFish utility and Hibernate-something.... but I will wait a bit on that.

I have Visual Studio but when I fiddled around with them I got lost. There's too much vocabulary etc. I don't know yet so I will return to that later.
I am less mad at Sun now.


* A page I did using ANFY in headline -
http://rockythedog.net/spooky/Glimpsesindex1/GlimpseIndex1.html
 
Last edited:
Toraidhe, It am showing my applet in a FORTE IDE.
I am writing it in notepad and cutting and pasting it in. I am doing this all from books (no class).
This is very short code -

int intSum ;
intSum = 14 + 35 ; // add
System.out.println ("The total is " + intSum) ;
System.exit(0) ; // stop executing


It is from Hour 14 in Sam's TYS JAVA in 24 Hours.
I am self-taught. . . as you can probably guess.
 
C# ... does have a similar level of placement, as a language, but is more Windows centric (there is a Linux and MAC target option, but using it on those platforms is a lot like using Java in Windows...complicated)

Clients install the JRE and they're done. Developers install the JDK and a good IDE (IntelliJ IDEA) and they're done. Usage is not "complicated in Windows".

It am showing my applet in a FORTE IDE.

Problem 1: You're using a 5-10 year old IDE from back when Sun maintained Java.

I am writing it in notepad and cutting and pasting it in. I am doing this all from books (no class).
This is very short code -

Problem 2: Use an IDE. They're there for a reason. IntelliJ IDEA Community or NetBeans (or Eclipse if you want an IDE that has decided it won't actually provide most of the benefits of an IDE) are all free.

int intSum ;
intSum = 14 + 35 ; // add
System.out.println ("The total is " + intSum) ;
System.exit(0) ; // stop executing
What's with System.exit? Just let main finish.
 
Last edited:
Outside the computers science domain, programmers are all self taught. It's by necessity of the rapid progression from industry. Whatever one learned to obtain a degree in the field is only a beginning thereafter. For example, just recently Apple released a new language called Swift for iOS development. Java didn't even exist during my own college years.

That said, there is a point where the science of computer software must be learned. It's independent of language (applicable to all languages), and gives you direction, tools and solutions. The simple examples are sorting, searching, storing data and strategies for handling typical problems. Just drawing lines requires a bit of computer science, traced back to Bresenham.

Your interest to branch out from Javascript is a clear indication of your interest, so you may as well consider mapping out a firm plan of study. For semi-professional or professional work, you'll need to know several languages (mostly these few already discussed). Unfortunately Javascript isn't a good first choice, but any will do. Java is a great first choice as a language. In the ancient epoch of computer science and industry, the 50's & 60's, the only language to start with was assembler.

Your objectives may be shaped by your age group and your underlying interests, which I can't guage from this thread thus far. My father walked this kind of path, in a previous technological environment, in his late 30's and 40's. His was purely curiosity and exploration. I walked this path in my childhood, at the earliest epoch that was commonly possible. Curiosity and childhood playfulness turned into a career.

There is, in my own view, a challenge, or difficulty, for Java oriented programmers. It's worse for those coming from other language orientations, like Javascript or BASIC. Java has considerable power. You can produce work on nearly any topic you can imagine outside of an operating system or device driver. It's possible you could learn Java and base an entire career solely using that language. Colloquially they're called Java programmers.

When faced with C++, Java programmers find C++ too ugly, too prone to problems. They tend to regard Java as superior and avoid C++. There are long running debates (arguments) between C++ programmers and Java programmers of almost a religious nature.

C++ programmers (I among them) find Java too limiting, too slow and lacking in features. Java programmers find these insulting accusations.

Yet C++ programmers have less difficulty working in Java than Java programmers find when working in C++. It has to do with familiarity and "upbringing" in their own history. C++ programmers are accustomed to the complexity and nasty pitfalls of the language, where as Java programmers find all of that unnecessary.

That would all be nothing more than opinion if it weren't for an underling fact. C++ is everywhere. It's foundation, C, is everywhere. It's the DNA origin of virtually all software on the planet. Java compilers and runtimes are written in C or C++. Operating systems are written in C (with C++ mixtures).

There are similar arguments between C programmers and C++ programmers, especially among those firmly positioned as operating system engineers and architects. You can't write for the Linux in C++. That must be in C.

Yet, outside that limited domain, C++ is the one language which delivers the portability once promised of Java. If, for example, a developer were to target code for Windows, Linux, OS X, iOS, Android, Blackberry, Tizen and any other operating system you might think of, the only language you can choose is C++. From one to another, some of those platforms rule out Java, or C#, or in one way or another aren't viable in anything other than C++.

I'm not telling you that you should study C++. What I saying is that it will be everywhere, a body of engineers and developers will use it and require it, and if you become so affiliated with any one language other than C++, you'll find yourself more on the "outside" than the "inside" of capability.

There are entire industries that only want Java developers, or C# developers. C++ will be of no help in getting a job in those industies. It's find to settle into a direction like that. Corporate usage, for example, tends to require database knowledge, web knowledge and application development knowledge firmly limited to Java, PHP, Javascript, HTML, SQL (and variants or alternatives for databases), Ruby, Perl and languages of those kinds.

If you were going to work on the servers they use, the compilers they require, the operating systems the depend upon (where you're not getting a job in a corporate environment), you're going to use C++. For game engines you'd need C++. (To make games you really need artwork, ideas, maybe someone else's game engine...you might not even need to 'code').

In other words, C++ is aimed at high performance, very ambitous work. Hardly anyone writes trivial or simple applications in C++ (except as short utilities in an operating system). Adobe Photoshop, 3DS Max, AutoCAD...these are C++ targets.

The point is that if you "settle in" to Java long term, it can make learning C++ seem quite difficult and uncomfortable. For now, you should focus on Java - it appears to be a direction with which you already have momentum.

Depending on how deep your motivations go, however, you'll need to study everything from the science to assembler, from C++ to D, without letting a preference for one language or another shape you.
 
In other words, C++ is aimed at high performance, very ambitous work. Hardly anyone writes trivial or simple applications in C++ (except as short utilities in an operating system). Adobe Photoshop, 3DS Max, AutoCAD...these are C++ targets.

Chicken and egg. If more people were aware that C++ is perfectly good for large and small and client and server applications, they'd be aware of Qt. If more people were aware of Qt, they'd be aware that C++ is perfectly good for large and small and client and server applications. Jetbrains (developers of IntelliJ IDEA) are developing a C++ IDE (CLion) recently, though, so maybe the chicken finally crossed the road and laid an egg.
 
As mentioned earlier, Applets are no longer supported in Java browser controls. If your goal is to be able to do interactive controls in web browsers i would suggest learning HTML5/CSS3/JavaScript. If your goal is browser games Flash/ActionScript. For anything else as a beginner i personally suggest C# for a beginner as it is working to be highly cross platform as well. I began my career learning to program in C++, then Java, and now C#. C# appears to me to have the brightest future for rapid development. (C/C++ will likely never go away as it gives too much control).

So my suggestion, find yourself a more up to date book for learning Java if that's what you want to learn (it is a good first language)
I learned using an earlier edition of this book
http://www.amazon.com/Java-Program-...1-1&keywords=java+how+to+program+10th+edition

And for an IDE if you need a decent freebie use Netbeans, but if you can afford to drop some money, the IntelliJ IDEA by Jetbrains is supposedly the best available.
 
system.exit
is from my tutorial (Sam's).

I did a lot of lessons in C++ and I like it also.
I happened to have an old book on JAVA here so I gave it a try. After my long applet hell experiment I want to try again with it in a different direction. If I get stuck again I'll move to JAVA EE. I know HTML5/CSS3/JavaScript... but I cannot earn anything from that. That's another story.

I am going back to basics and skipping this applet-in-a-web page project for now. Great info for me here to slog on forward with so thanks, everybody.
I have Net Beans IDE to use also. I liked FORTE because it was simpler.
 
Last edited:
Onward and onward.
Well it sure is true applets are definitely a thing of the past.
As a more simple tool I am trying Code Warrior from Motorola. But they got bought out and the 6 mos. old product is probably not supported anymore.
I like it because it is like Visual Studio but a much easier interface for a beginner.
I fooled with Visual Studio for about a week and got worn out.

Next project .... see if there's something I can code in Code Warrior system that isn't an applet.
It works well ... just not in a web page =sigh=.
After this I will get going with GlassFish deal.
I want to pet a kitten before I get in a cage with a tiger.
 
Back