Java SE Error in cmd [closed] - java

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I downloaded Java SE Development Kit 7u7 and then I tried to make a simple program in Notepad to see if it works.I wrote the program , saved it in notepad.
(Note: As I was saving I noticed that in the Save as type the java extension wasn't there, so I just added .java at the end of the name of my program)
For this java I tried using cmd but as far as I have understood, it doesn't find it. As error it says the first world of my first file i try to use "is not recognized as an internal or external command, operable program or batch file". Could there be a problem with my PC , the java or does this have to do with the fact that I used Notepad instead of Notepad++ wich I have heard is better than the simpler one?

Maybe Notepad saved your file as YourProgram.java.txt.
You need to enable "View extensions" to see the real extensions. Here a step-by-step guide how to enable: http://windows.microsoft.com/en-US/windows-vista/Show-or-hide-file-name-extensions.
Open Folder Options by clicking the Start button, clicking Control Panel, clicking Appearance and Personalization, and then clicking Folder Options.
Click the View tab, and then, under Advanced settings, do one of the following:
To display file extensions, clear the Hide extensions for known file types check box, and then click OK.

Java source code files are not executable. You must compile it first using javac (this will produce a MyClass.class file) and then run using java MyClass. This is just the very basic information, there's actually a lot more to it, but I hope this will give you a starting point. You really should consult an online tutorial on the subject and definitely start working with a Java IDE such as Eclipse right away. Developing with Notepad is in fact much more involved, especially for a beginner, than with Eclipse.
Second, you have quite probably saved a file named MyClass.java.txt. Notepad adds the extension according to the chosen file type implicitly.

Check this video, it's about set up the java(JDK) path in windows 7!
and as advice for you, use Eclipse IDE or whatever you like to use!

Related

Putting both source code and executable file in CD/DVD

I want to burn my program in CD?DVD booth as an executable file, together with source code. How can i do that?
Suppose you already have a working CD/DVD with executable (autostart working etc.), you can simply put the source code on GitHub/GitLab or else and add a link to the manual. You are publishing the source code anyway, then you can already do it the "standard" way.
Of course this only works if all your users have access to the internet.

invocation of dll from java , edit dll source code

I am using an open source jar from github and its running ok. While using the library API the program pops a message box and waits for user to click the ok button. I checked it via debugger and apparently a dll file in the native directory gets invoked and it is responsible for the messagebox, after clicking ok the output is what excepted. I guess my question is how to skip this message box or alternatively how can I just programmaticaly click the ok button so the program wont be halted until clicking the button. I try editing the dll file but its a binary code, and there is no way to edit a jar file and and re-compile it to work again, so I'm kinda stuck.
I believe that if I can watch the source code I can change the function itself and it should work but im unable to pull this off. I understand that the dll file before compilation probably was written in C, C++ or C# so I guess the only problem is getting to the dll file itself. i don`t beleive a sample code is required here.
Thank you in advance!
To decompile/reverse-engineer the DLL (if written in C#), you can use the free .NET decompiler from JetBrains: dotPeek. If written in C/C++, it will be much harder to reverse engineer the DLL and I would recommend using some sort of test automation software. Ranorex is a good paid one, and SikuliX is a free one that can probably accomplish what you need.

How to Recompile Deconstructed EXE

I had some software developed on oDesk about a year ago. What I get back is a java based .EXE
It runs as a standalone without any sort of installation. The problem is they screwed up some graphics for the buttons, it didn't bother me at the time, because I got what I wanted, a minimal viable product that got the job done.
With that said, it's been bothering me for a while, and when I reach back out to the guy - I can't get him.
I used 7zip to open the .EXE and extracted all the contents. I found where the buttons were and fixed them, obviously trying to drag it into 7Zip in the specified location isn't going to work.
How do I go about recompiling everything?
I'm new to all this, so if you need any additional information, please don't hesitate to ask. I just want this thing to look as I intended.

Launching a Java program via double click [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I have a Java program that I have been working on. I would like to show it to my girlfriend, who would have no clue as to how to work with Java, and make it easy for her to do so. I understand the first step is to compile it to .class 's from the command line, but after that I am clueless.
I would be interested in finding out how to do this both for Windows and Mac OS (I am on a Mac, along with my girlfriend, but my school uses Windows computers).
I have been on Oracle and seen their demos, they download as .jnlp, is that a step in the right direction?
And specifically, I am looking for a "file" of some sort that is simply downloaded and launched, no terminal involved (maybe a file with a command line within?).
Launching a Java program via double click
..seen .. demos, they download as .jnlp, is that a step in the right direction?
The title and that quote typically represent two different ways to launch Java desktop apps.
"download as .jnlp" That is the 'deluxe' version, known as Java Web Start. It is a little trickier for the developer (you) but very easy for the user (your friend).
"Launching a Java program via double click" is more commonly associated with an executable Jar. (Although JWS also supports the 'double click' - but with menus and shortcuts.)
Either strategy will work on OS X, Windows or *nix, but the first has JRE versioning (making sure the end user has a JRE, and it is recent enough to run the code) assisted by scripts, and many other 'bells and whistles'.
Java Web Start
JWS apps. typically deployed from a web page or server accessible to the user machine, so your friend 'surfs on over' to the link you sent her to 'Download here'.
The moment she arrives at your web page, the deployJava.js will check her PC has a suitable minimum version of Java to run the app. If not, she will be guided through a process to get it.
When the JRE is confirmed (which happens invisibly for those with a later JRE) the script writes a link in the web page that by default is a button.
The user clicks the button and the JWS client (part of Java) will read the JNLP and begin to install the app.
If the app., requires permissions extended beyond the default sand-box, the user will be prompted as to whether to allow the code to run. See Appearance of Java Security dialog for more examples like:
If the user chooses Run ..
The app. will be loaded and appear on-screen (possibly along with desktop shortcuts and start menu being added).
To launch it the second and subsequent times, the user double clicks the desktop shortcut or activates the menu item. This is how Starzoom (which has an icon defined in the JNLP) appears in Windows 7.
Executable Jar
Another lesser alternative is an executable-jar.
It uses a manifest.mf in the Jar that specifies the main class.
While being a lesser experience for the end user, it is also simpler for the developer - a trade off that might come in handy for limited distribution.
Requires a suitable version JRE installed.
The user obtains the Jar from whatever source (USB, Bluetooth, web site etc.) and saves it anywhere on their machine that is convenient.
To launch it, the user double clicks the Jar.
You could create a bat script (Windows, I don't use OSX, but i think it's shell script for that) with the Java command you use to execute your Java program.
Or you could put you java class into a JAR file
Try NetBeans, make a project in there, and build your codes with it. It automatically produce jar file that can be execute via double click almost in any platform.

Proper method to find user's My Documents folder on Windows with Java?

For whatever reason, I sometimes need to find the current user's My Documents folder on Windows in a Java program to read some files. But as far as I can tell, there is no way to do it that isn't severely flawed.
The first wrong way: System.getProperty("user.home");
Why it won't work:
It only returns the \username\ folder; I'd need to add "\Documents\" on to the end to get the Documents folder... and that only works in English.
Sun bugs 6519127 and 4787931. Java finds the user home folder on Windows by reading a deprecated registry key* to find the Desktop then taking the parent; this method has multiple known problems that will easily cause a completely wrong folder to be returned. The bugs are 3.75 years and 8 years old with no fix.
The second wrong way: Using a registry-reading program to get the Personal folder of the user, which is My Documents (but i18n'd).
Why it won't work:
While it fixes the English-only problem, it's still using the same deprecated registry area, so the bugs still apply to it.
The deprecated registry key says to use a native call (SHGetKnownFolderPath) which I obviously can't do from Java.
The third wrong way:
JFileChooser fr = new JFileChooser();
FileSystemView fw = fr.getFileSystemView();
File documents = fw.getDefaultDirectory();
Why it won't work: It works great!
Except when it doesn't. While I had a program that used this open and running in the background, I opened a DirectX game (Fallout: New Vegas). The Java program immediately terminated with no stack trace. Always reproducible (for me on that game, and who knows what else). Couldn't find a Sun bug#.
So is there any method to find a user's Documents folder, on Windows, from Java, that doesn't have known problems?
(This is a nice big question.)
*(The key is "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
There's no pure java way to do it, but you could use the JNA wrapper over JNI to do it without having to write any native code yourself. There's a good example of how to get the Documents folder on Windows halfway down the responses at:
What is the best way to find the users home directory in Java?
A time consuming, but reliable way of finding the 'Documents' folder of a windows user: Make your java app execute a bat script that uses Reg.exe (a windows system file) to find the value of the reg key which has the path in it. Then use a pipeline in the same bat file to send that data to the 'findstr' function which windows command prompt has. Use another pipeline to output the returned value to a text file. Then, simply make your java app read that text file, and delete it once its done :) Worked well enough for me.
Code for the bat file:
# echo off
Title Find Documents Folder
Reg Query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" |findstr "Personal">>DocPath.dat
exit
There is a custom Java API that someone built (their website no longer works), but there code remains on Google Code:
http://winfoldersjava.googlecode.com/files/WinFoldersJava_1.1.zip
There are two DLL's that need to be referenced, one for each architecture(x86 and x64).
user.home is not "my documents", but users home folder, like on Unix ~/.
To get to "My documents" you can use System.getProperty("user.home")+"\Documents"; irrespective of the language system. Try it.

Categories