How to get NetBeans to recognize acm graphics library (Java) - java

How to get NetBeans to recognize that I have the ACM libraries installed on my computer? I've copied/pasted it into several locations, but always get the same error (basically saying that the package doesn't exist). I've read on a few sites there is a java archive ("jar") file involved, but I don't know if I have it, how to create it if I don't, or where to install/copy it if I do.
As far as details go, I have a PC running Windows 7, JRE 7, and jdk1.7.0_21. I have a "64-bit" computer, if that means anything (I know what a bit is but have no idea whether it would affect Java or NetBeans). The error rears its ugly head when I try "import acm.graphics.*;" and similar statements. The full error message is: "package acm.graphics does not exist".
I'm fairly new to NetBeans and I'm thinking it's probably something simple, and it would really be great to be able to use the ACM libs, so any ideas for fixing the problem would be most appreciated. Thanks.

Related

How do I track what java is actually looking for as it traverses CLASSPATH?

How is the java utility that begins the process of launching a class told to "spill its guts" on what it's doing as it tries to load classes?
In particular, what file paths is it TRYING to access, only to perhaps discover whatever it's looking for is not there, at least as it interprets the specification given? There was a way to get that information, but I can't find it now.
Note that this is Java version "1.8.0_333" on Windows 10.
I've tried every flag known to me, via the -h and -X flags, and I strongly suspect what I'm looking for is (was) an X flag that's been removed, just as the -X help output warns. And so, there must be an OS way to figure this out, I sure hope!
You might ask why? Whatever for? What are you trying to do? Well, that's the bulk of this question's text. To wit:
As one of the very early users of Java (I started with 1.1) way back in the '90s, I had an issue moving an application suite I'd written for my company on Linux to MS Windows and I got it working by using Cygwin. Along the way, this same sort of issue came up and I quite vividly recall having found a mechanism for getting the Java launcher to articulate just what file specifications - paths - it was actually using in searching for the appropriate class. And through using this, I found that the CLASSPATH was being specified incorrectly, and with some experimentation, I got it working reliably. Now I need to do that again!
This flag I'd used was immensely helpful in figuring out just what the file specification format CLASSPATH needed to be (we're not talking semicolons here) this combination of OS, Java, and Cygwin. After some hours of what I hope was reasonable hunting, I'm wondering if this capability has been removed at some point? Either that or "I'm looking for the wrong thing." Heck, since the source is available (I think!), maybe some brave soul has hacked the java utility to do such a thing?
It may help to understand that for this application I wrote for my company, it was a major goal to have the source work pretty much the same on all Windows and Linux / Unix systems (and at the time, macOS), and just use a configuration file to tell the code what's different. And that wasn't easy to figure out, but with this flag, it wasn't that hard, either.
But, unfortunately, I haven't needed this knowledge since I figured it all out all those years ago, and apparently, this little kernel of knowledge is very hard to find today. Or, it's no longer pertinent to the modern version(s).
I don't think this has anything much to do with the actual problem, but it may help in people's thinking if they understood the scenario: The current situation is that I have a fully functional installation of this software on Windows 7 to use as a comparison for how to configure things on Windows 10 (and hopefully younger). The Windows 7 is running a pretty modern Cygwin installation and very nearly the most modern Java - just a sub-version away from the new installation from last week on a Windows 10 box. (Everything's bright and shiny new on the new box.)
The required format for CLASSPATH on the nearly identical but fully functional Windows 7 system is:
CLASSPATH="C:/opt/OurInstallationDir/lib"
And that's it.
This value is picked up in several places as the code later needs to launch Java itself to do some unusual things. However, the java command that gets it all going is launched from a C program - not that that matters for this problem - but the C program (compiled under Cygwin, but perfectly runnable from any Windows environment) helps ensure that the Java environment is secured (policy file contents and so forth) before getting into Java, else it refuses. And this program on Windows 11 launches Java just fine, it's just giving it a CLASSPATH that isn't useful, apparently, even though the files are there where they should be, etc.
Configuring things as before just doesn't work, even from the command line. No version of specifying CLASSPATH seems to work if it's more than a dot; the only thing that works, is being in the /lib directory when starting and using "-cp ." ... But that's just not going to fly for so many reasons! To be a little more clear, I've tried reversing the slashes, using /cygdrive/c/, and whatever else I could think of. But, at least we know that if you're in the directory and use -cp, it will find and launch the program. So, there's nothing wrong with the Java, just pointing the java utility at it.
Again: How is the java utility that begins the process of launching a class told to "spill its guts" on what it's doing as it's trying to load classes?
You use this construct on the JVM:
java -XX:+TraceClassPaths -cp "C:\opt\SomeDirectory\lib" myClass
I was able to get confirmation of what Java was using, not only for my CLASSPATH, but "internally" by using the above.
The fact that it echoed back both what I was doing and what it was doing somehow gave me the insight to check everything about it. Java itself doesn't work (at all) if it's installed in a location that it thinks has a link in it, and it's own fetches go right back to the system disk specification.
From that I found that Java on Windows won't take a CLASSPATH that has a link in it!
Simply ensuring that the whole tree was specified "from the top" of the drive it's on works. If it's not, it won't.
It's now working happily using the syntax noted above.
This is quite different from every other application I've seen on Windows. But, well, it's Java!
This really came from a pointer from Mark Rotteveel who commented above about this article: How to track when class is loaded and destroyed in jvm? And therein I learned how to get the list of all the options the presently in-use JVM supports. All Java developers should be aware of this in my opinion, so thanks to Mark for that.

Export a JavaFX project in eclipse to a runable jar

I need to send a project made by JavaFX SDK 16 and Java SE-15 using Eclipse to my friends, but when I try to export it, i'm getting surprised that Eclipse doesn't insert the VM arguments to the exported file :
and as you know since JavaFX SDK 10, JavaFX libraries are not anymore part of the Java SE, so we need to tell Eclipse where to find them by VM arguments, in short words, these VM arguments are really important to run my program.
I already know that I can insert those arguments while using prompt command to open it, but is there a more simple way? just by clicking on the exported file ?
Your main problem is that you are trying to do something that does not make any sense. Runnable jars are not a proper distribution format for JavaFX applications for various technical reasons. The way to go is having a look at jpackage. That's the proper way of dealing with distribution nowadays. Otherwise your are just banging your head against a wall.
Here is a good summary of all the options you have: https://stackoverflow.com/a/68823040/4262407
I have this problem 5 years ago (I use netbeans IDE, so I don't know if it works in eclipse, but I think yes), and I cant find a good way to do this.
Instead, I created one Swing application, and put all code of JavaFX inside.
You could see how I do in
this link from Oracle.

Eclipse does not recognize Java 7 on Mavericks, can't find jdk.1.7.0_51 to fix issue

Now, the problem of not being able to use Java Development Kit 7 with eclipse on Mac computers seems to be a problem a lot of people have. After digging around, I found what seemed to be a widely accepted solution here: Eclipse Kepler for OS X Mavericks request Java SE 6
The problem is, there are no files in /Library/Java/JavaVirtualMachines. I enabled hidden files but still found nothing. I looked around for more solutions, but they all seem to involve the jdk.1.7.0_xx file. I have tried reinstalling java (downloaded from the java site) multiple times but no files appear.
Now, I could try installing Java 6, but it's kind of a pain to download on a 30kbps internet connection, so I would prefer if there was another way. Plus, it's concerning that a file that everyone else seems to have is missing.
So, my question is: Is there any way I can acquire this file (separate download, something I missed, etc) or do I have to download Java SE 6? Any answer would be appreciated.

can you create java file from the class file? Decompile

I recently created a project in Netbeans using VirtualBox on which i installed windows XP (Not activiated)
My Windows required me to activate and would not allow me access to my files on the computer before i activate it, i stupidly went and uninstalled XP and reinstalled it, thinking i'll have access to all the files from the JAR file i created
I want to know if theres any way i can use the class files of the project i created, to create new java files so that i can edit the code in netbeans ??
Please if anyone can shed some light on this topic, if its at all posible to gain access to the forms java content i created. Im new to programming and this is something above my knowledge (i hope this makes sense)
If not possible please let me know what an absolute idiot i am, so that i can start re creating the project from scratch ... Sigh, and thank you
A jar/class file is compiled bytecode that is not human-readable... but with Java it is easily converted back. Look into a program like JavaDecompiler.1 This is not my program but I use it and I find it workable for my needs.
1 If this is considered spam I'll gladly invalidate the link.
As a sidenote: You are lucky that its Java. In many other languages like C++ that would hardly be possible. The difference is that Java does not compile the source code to machine code. That step is hardly reversible since for example all variable names are lost. Try to understand a non-trivial piece of code without helpful variable names...
Java instead compiles the source code to byte code which then is interpreted by Java on runtime. That byte cold holds way more information about the original source code than machine code.

Eclipse and JavaFX? is it just me?

I'm looking at learning JavaFX.
I've tried setting Eclipse to develop a small app and I've downloaded the Eclipse plugin.
Eclipse JavaFX plugin
BUT... it just seems, well, flakey.
So I have 3 questions...
1: Is there a better plugin?
2: Or is there some great set of tutorials out there that I'm missing?
3: finally, is it meant to be easy to call Java code from FX? I'm stuggling, it there a good example somewhere?
On questions 1 & 2, Eclipse underlines code in red that just shouln't be. For example..
see this image... alt text http://www.qenet.co.uk/fx.jpg
Why does it underline bit of imports in red?
I know this is little of an open ended question. So I guess my main question is this...
Is my experiance of JavaFX and Eclipse the best I can hope for? Or am I missing something ?
(and I'm not looking for a Yes/No response) :-)
Just looking for a discussion on how best to learn/develop JavaFx.
This kind of thing is not unusual. A lot of Eclipse plugin editors have problems dealing with error tags and the like. For example,
I find that the XML and HTML file editors often fail to clear error and warning markers, and the only way to get rid of the markers it is close and reopen the file.
Even the Java viewer gets it wrong in some circumstances, though the problem goes away when the relevant files are saved.
When you update a spelling dictionary, the spelling checker is not rerun and the spelling error markers are not updated. In fact, you have to restart Eclipse for this to happen.
I suggest that you try saving files, and closing/reopening editors to see if that makes the bogus error markers go away. Then decide whether Eclipse is the right IDE for this task.
I've never used NetBeans (at all), but you would expect that it would do a better job supporting JavaFX. After all NetBeans and JavaFX are both high profile Sun products at the moment.
Netbeans is really the only way to go at the moment for JavaFX development. They are both Sun products and Sun has made sure the two work very well together. Before long Eclipse and others will catch up but for the moment that's how it is.
There is another JavaFX plug-in for Eclipse from Exadel. You can download it here: http://exadel.org/javafxplugin. Give it a try.
I have similar problems but funnily only under Linux, not Windows. Hope they change that soon.
To me this has happened when I wronlgy installed javafx sdk 1.2.3....This plugin works only with 1.2.1... :/

Categories